ubuntu的FTP服务器搭建

2023-11-09

1、安装服务器

sudo apt-get install vsftpd

如果有错误,先执行

apt update

2、创建用户(Linux下的用户)

创建专用目录

mkdir /home/ftp

命令添加ftp用户

sudo useradd -d /home/ftp/uftp -M uftp   //  用户名为uftp
sudo passwd uftp    //设置密码
chown ftp_mofeng:ftp_mofeng /home/ftp/ftp_mofeng/
chomd 777 -r /home/ftp/uftp(这个也行)

命令格式解析

-d:设置用户文件夹
-m:设置用户名

其他命令

##限定用户test不能telnet,只能ftp
usermod -s /sbin/nologin uftp   
##用户test恢复正常
usermod -s /sbin/bash uftp   
##更改用户test的主目录为/test
usermod -d /home/ftp/uftp uftp

3、修改配置文件

将上面新建用户添加到里面,一行一个

sudo vi /etc/vsftpd.chroot_list
sudo vi /etc/vsftpd.conf

配置文件全部内容(替换即可)

# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
#
# Run standalone?  vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
listen_ipv6=YES
#
# Allow anonymous FTP? (Disabled by default).
#这个是设置是否允许匿名登录ftp服务器,不允许。
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
#是否允许本机用户登录
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
#允许上传文件到ftp服务器
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories.  See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
chroot_list_enable=YES
# (default follows) 允许chroot_list文件中配置的用户登录此ftp服务器。
chroot_list_file=/etc/vsftpd.chroot_list
 
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
 
#
# Uncomment this to indicate that vsftpd use a utf8 filesystem.
#utf8_filesystem=YES
#配置ftp服务器的上传下载文件所在的目录。
local_root=/home/ftp/
#被动模式的端口范围
pasv_min_port=1025
pasv_max_port=2025
#this directory is for ftp server to save  download or upload data

配置文件其他部分详解

# 禁止匿名用户登录
anonymous_enable=NO
# 允许系统用户登录
local_enable=YES
# 启用可以修改文件的 FTP 命令
write_enable=YES
# 本地用户创建文件的 umask 值
local_umask=022
# 允许为目录配置显示信息,显示每个目录下面的message_file文件的内容
dirmessage_enable=YES
# 开启日记功能 
xferlog_enable=YES
# 使用标准的20端口来连接ftp 
connect_from_port_20=YES
# 使用标准日志格式 
xferlog_std_format=YES
# ftp服务器将处于独立启动模式
listen=YES
# 设置一个本地用户登录后进入到的目录
local_root=/home/ftp/ftp_mofeng
# 设置PAM认证服务的配置文件名称,该文件保存在“/etc/pam.d/”目录下
pam_service_name=vsftpd
# ftp将检查userlist_file设置文件中指定的用户是否可以访问vsftpd服务器
userlist_enable=YES
# 只允许user_list文件中记录的ftp用户能登录vsftp服务,其他的ftp用户都不可以登录。
userlist_deny=NO
# 定义限制/允许用户登录的文件
userlist_file=/etc/ftpusers
# ftp服务器将使用tcp_wrappers作为主机访问控制模式
tcp_wrappers=YES
# 连接ftp服务器使用的端口
listen_port=21
#( chroot jail是类unix系统中的一种安全机制,用于修改进程运行的根目录环境,限制该线程不能感知到其根目录树以外的其他目录结构和文件的存在。(详情参看chroot jail)。
# 有时我们需要设置根目录(chroot)环境来禁止用户离开他们的家(home)目录。
# 在配置文件中增加/修改下面配置开启根目录限制(Chroot Jail)
#(“chroot_list_file”变量指定根目录限制所包含的文件/目录( 即用户只能访问这些文件/目录))
chroot_list_enable=YES 
chroot_list_file= /etc/vsftpd.chroot_list

备注

# 欢迎标语
ftpd_banner=Welcome to use my test ftp server.
# 接下来的三条配置很重要
# chroot_local_user设置了YES,那么所有的用户默认将被chroot,
# 也就用户目录被限制在了自己的home下,无法向上改变目录。
# chroot_list_enable设置了YES,即让chroot用户列表有效。
# ★超重要:如果chroot_local_user设置了YES,那么chroot_list_file
# 设置的文件里,是不被chroot的用户(可以向上改变目录)
# ★超重要:如果chroot_local_user设置了NO,那么chroot_list_file
# 设置的文件里,是被chroot的用户(无法向上改变目录)

4、启动服务

# 启动ftp服务
service vsftpd start
# 查看ftp服务状态
service vsftpd status 
# 重启ftp服务
service vsftpd restart
# 关闭ftp服务
service vsftpd stop
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ubuntu的FTP服务器搭建 的相关文章

  • 检查 Linux 中给定进程的打开 FD 限制

    我最近有一个 Linux 进程 泄露 了文件描述符 它打开了文件描述符 但没有正确关闭其中一些文件描述符 如果我对此进行监控 我就可以提前得知该过程已达到其极限 有没有一种很好的 Bash 或 Python 方法来检查 Ubuntu Lin
  • mod_perl 无法看到 /tmp 中的文件

    我有一些 mod perl 代码试图访问 tmp 下的文件 但它抛出 没有这样的文件或目录 错误 我在代码中添加了一个 ls al tmp 来查看 Perl 在目录中看到的内容 它只给了我 和 drwxrwxrwt 2 root root
  • 警告构建使用导出符号的内核模块

    我有两个内核模块 例如 modA 和 modB modA 导出一个符号EXPORT SYMBOL symA modB 使用它 我有标题modA h对于modA extern void symA int param and in modB c
  • matplotlib 中没有绘图窗口

    我刚刚使用 synaptic 软件包系统在 Ubuntu 9 10 中安装了 matplotlib 但是 当我尝试以下简单示例时 gt gt gt from pylab import plot gt gt gt plot 1 2 3 1 2
  • 终止 ssh 会话会终止正在运行的进程

    我正在使用 ssh 连接到我的 ubuntu 服务器 我使用命令启动编码程序 然而 似乎当我的 ssh 会话关闭时 因为我在进入睡眠状态的笔记本电脑上启动它 有没有办法避免这种情况 当然 阻止我的笔记本电脑休眠并不是永久的解决方案 运行你的
  • 如何将字符串推送到标准输入?在启动时通过 stdin 提供输入,然后以交互方式读取 stdin 输入 [重复]

    这个问题在这里已经有答案了 有没有办法在调用程序时将字符串 推送 到程序的标准输入流 这样我们就可以达到这样的效果 echo something my program 但不是在之后读取 EOF something my program将从原
  • 并发 I/O - 缓冲区损坏、块设备驱动程序

    我开发块分层设备驱动程序 所以 我拦截WRITE请求并加密数据 并解密数据end bio 例行程序 在处理和READ要求 所以在单流中一切正常 但是 如果尝试同时从两个或更多进程执行 I O 我会遇到缓冲区内容损坏的情况 我没有任何本地存储
  • gnutls_handshake() 失败:握手失败 GIT

    一切都工作正常 但突然我收到错误 致命 无法访问 https 电子邮件受保护 cdn cgi l email protection name repo name git gnutls handshake 失败 握手失败 我在我的计算机和 E
  • 如何搭建qtwayland?

    我花了一整天的时间尝试使用QtWayland Compositor 1 0在 Qt 创建者中 我已经遵循了从那里开始的所有步骤https wiki qt io QtWayland https wiki qt io QtWayland但我收到
  • 打破条件变量死锁

    我遇到这样的情况 线程 1 正在等待条件变量 A 该变量应该由线程 2 唤醒 现在线程 2 正在等待条件变量 B 该变量应该由线程 1 唤醒 在我使用的场景中条件变量 我无法避免这样的死锁情况 我检测到循环 死锁 并终止死锁参与者的线程之一
  • 多线程进程的线程ID可以与另一个正在运行的进程的进程ID相同吗?

    我正在尝试找到一种方法来唯一标识多进程环境中的线程 我有一个服务器 它跟踪连接到它的不同进程 其中一些是多线程的 一些不是 为了识别多线程连接中的线程 我使用线程 ID 作为唯一标识符 在任何给定时间最多有 1 个多线程进程连接 我的问题是
  • 第一次如何配置postgresql?

    我刚刚安装了 postgresql 并在安装过程中指定了密码 x 当我尝试做的时候createdb并指定我收到消息的任何密码 createdb 无法连接到数据库 postgres 致命 用户密码身份验证失败 同样适用于createuser
  • 在 Windows 下使用 linux 实用程序的最佳方法是什么? [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 Linux 实用程序 如 sed awk 和其他 shell 脚本功能 非常棒 但当我在 Windows 上进行开发并且无法使用其中任何一
  • socket.io 自动断开套接字

    当我在电子中运行 socket io 时 我不断在开发者控制台中收到此错误 engine io client socket probe transport websocket failed because of error transpor
  • 仅为我自己禁用和重新启用地址空间布局随机化

    我想在我的系统 Ubuntu Gnu Linux 2 6 32 41 server 上禁用地址空间布局随机化 ASLR 但是 如果我使用 sysctl w kernel randomize va space 0 我认为这一更改将影响系统上的
  • Microk8s 节点未准备好 - InvalidDiskCapacity

    microk8s的节点不想启动 Kube system Pod 处于挂起状态 kubectl describe nodes说是警告InvalidDiskCapacity 我的服务器有足够的资源 PODS NAMESPACE NAME REA
  • 如何让 VSCode 在当前工作区中打开?

    我在 Linux 上使用 VSCode 我有多个 Linux 工作区 当我在新工作区中的 VSCode 中打开新文件时 它会在原始工作区中的 VSCode 中打开一个新选项卡 而不是在当前工作区中打开 VSCode 的新实例 这确实是令人讨
  • 超立方体错误。非法的最小或最大规格

    尝试从这里运行示例代码http tess4j sourceforge net codesample html http tess4j sourceforge net codesample html我收到一条错误消息 Error Illega
  • copy_from_user() 错误:目标大小太小

    我正在为内核模块编写 ioctl 处理程序 我想从用户空间复制数据 当我编译禁用优化的代码时 O0 gflags 编译器返回以下错误 include linux thread info h 136 17 error call to bad
  • 在linux中将包含word的行从一个文件复制到另一个文件

    我想复制包含某些单词的行file1 to file2 Suppose file1 ram 100 ct 50 gopal 200 bc 40 ravi 50 ct 40 krishna 200 ct 100 file2应该只有包含 ct 的

随机推荐

  • 从代码生成到问题解答,InsCode AI助你成为编程及写作高手

    目录 前言 InsCode AI写作助手 创造更好的写作体验 InsCode AI 创作助手 如何帮助创作者高效创作文章 结论 个人感受 一 你平时会使用这类AI工具吗 你对这类型的工具有什么看法 二 你可以花几分钟体验一下InsCode
  • 新的刷脸支付方式掘起手机支付将会終结

    手机支付将会終结 新的支付方式掘起 新的支付方式对很多人还是很陌生的 这就要很好的推广和布置 现在推出了二代的蜻蜓刷脸设备 向商户销售出了舒缓的二代蜻蜓刷脸支付设备 超市 快餐厅 自动贩卖机都已经实现商业直播 相信很快在每个城市 都会发现这
  • 重载new/delete(C++中的new/delete与operator new/operator delete)

    转 http blog csdn net zhangxiao93 article details 50768025 原文 http www cnblogs com luxiaoxun archive 2012 08 10 2631812 h
  • k8s的dashboard日常操作

    k8s的dashboard日常操作 一 k8s的dashboard介绍 1 dashboard介绍 2 dashboard的功能 集群管理 工作负载 服务发现和负载均衡 存储 配置 日志视图 三 查看集群的所有角色 四 查看集群的命令空间
  • Python数据结构-----递归实现快速排序

    目录 前言 快速排序 1 概念 2 示例 Python代码实现 递归实现快速排序 前言 今天我们就来一起学习快速排序的思想方法 然后通过Python语言来实现快速排序的功能 下面我们就开始今天的学习吧 快速排序 1 概念 快速排序其实是冒泡
  • 使用ggplot2包绘制分组带状图实战

    使用ggplot2包绘制分组带状图实战 在数据可视化中 分组带状图是一种常用的图表类型 可以直观地展示多个组别之间的差异和变化趋势 而R语言中的ggplot2包提供了丰富的绘图函数 其中geom jitter函数可以用来创建分组带状图 下面
  • SpringBoot + Websocket 实现实时聊天

    SpringBoot WebSocket 实现实时聊天 最近有点小时间 上个项目正好用到了websocket实现广播消息来着 现在来整理一下之前的一些代码 分享给大家 WebSocket协议是基于TCP的一种新的网络协议 它实现了浏览器与服
  • ctfshow-web10 with rollup 绕过

    0x00 前言 CTF 加解密合集 CTF Web合集 网络安全知识库 文中工具皆可关注 皓月当空w 公众号 发送关键字 工具 获取 0x01 题目 0x02 Write Up 基本方法 到处点一点 点到取消的时候 突然发现 可以下载一个文
  • C语言中signed和unsigned怎么理解?C语言unsigned long、long long 取值范围???

    C语言中signed和unsigned signed意思为有符号的 也就是第一个位代表正负 剩余的代表大小 例如 signed int 大小区间为 128 127 unsigned意思为无符号的 所有的位都为大小 没有负数 例如 unsig
  • java实现下载excel读取与生成超详细

    背景 没啥背景 就是要做这个功能 创建ExcelUtil工具类 具体导入导出方法如下 excel导入 param inputStream 导入的excel文件 return public static List
  • 酱香咖啡喝了没?用数据分析揭秘瑞幸咖啡的7500万用户增长策略

    瑞幸 X 茅台 这波联名赢麻了 不仅狂卖 542 万杯 甚至带动茅台市值飙升200亿 瑞幸这几年联名搞了不少 又是线条小狗的爱情故事 又是椰树 维密 周大福 足球的 下面老李就从数据分析角度 带大家来看一下近几年 瑞幸咖啡的用户增长策略 是
  • 数据结构笔记之链式栈的基本操作

    include stdio h include stdlib h include io h include math h include time h define OK 1 define ERROR 0 define TRUE 1 def
  • VMWare安装

    1 1 VMWare简介 VMWare是一个虚拟技术的合集 它提供了众多的相关软件 类似于Parallels VMWare是商业应用 而且价格非常的贵 所以 通常我们使用的是网上别人破解的版本 而不是使用官方的正版 VMWare官网 VMw
  • 【UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd3 in position 0: invalid continuation byte】

    UnicodeDecodeError utf 8 codec can t decode byte 0xd3 in position 0 invalid continuation byte F jupyter work dir MMLAB m
  • 有一个公网IP,在内网如何架设多台服务器?

    进行内网ip到外网ip的映射 也就是pat 这个工作现在多半由防火墙来完成 不过如果没有防火墙 用路由器也可以完成 只不过会在高峰时加重路由器的负担 思科2600路由可以独立完成各种nat pat但是因为这款产品本身属于低端产品 所以能够担
  • Java8学习记录(一)——Lambda表达式

    这两天看了 Java8实战 做一下记录 目录 一 行为参数化 1 什么是行为参数化 二 函数式接口 1 概念 三 Lambda表达式 四 方法引用 注意点 1 静态方法引用 2 实例方法引用 重点来了 任意类型的实例方法引用 现有对象的实例
  • 【深度学习】树莓派Zero w深度学习模型Python推理

    在机器学习开发过程中 当模型训练好后 接下来就要进行模型推理了 根据部署环境可分为三类场景 边缘计算 一般指手机 嵌入式设备 直接在数据生成的设备上进行推理 因为能避免将采集到的数据上传到云端 所以实时性非常好 端计算 介于云和边缘设备之间
  • Spring Boot 集成Mybatis实现多数据源

    总体来说多数据源配置有两种方式 一种是静态的 一种是动态的 静态的方式 我们以两套配置方式为例 在项目中有两套配置文件 两套mapper 两套SqlSessionFactory 各自处理各自的业务 这个两套mapper都可以进行增删改查的操
  • GPU版本安装Pytorch教程最新方法

    目录 步骤 第一步 安装 Anaconda 和 Pycharm 软件 第二步 下载安装CUDA11 3 1 首先查看自己电脑GPU版本 方式一 搜索框输入nvidia 打开nvidia控制面板 方式二 win R打开cmd 输入nvidia
  • ubuntu的FTP服务器搭建

    1 安装服务器 sudo apt get install vsftpd 如果有错误 先执行 apt update 2 创建用户 Linux下的用户 创建专用目录 mkdir home ftp 命令添加ftp用户 sudo useradd d