#服务端安装vsftpd
$ yum -y install vsftpd
#配置vsftpd.conf文件
$ vim /etc/vsftpd/vsftpd.conf
#修改的内容
# 是否允许匿名登录(将其禁止)
#anonymous_enable=YES
# 设置连接超时时间(单位秒)
idle_session_timeout=600
# 数据传输超时时间(单位秒)
data_connection_timeout=120
# 是否允许上传/下载二进制文件
ascii_upload_enable=YES
ascii_download_enable=YES
# 限制所有的本地用户只能访问自己的目录
chroot_local_user=YES
# 是否允许使用ls -R等命令
ls_recurse_enable=YES
#新增的内容
# 是否只允许userlist_file文件中的用户登录FTP服务器,userlist_enable为YES才生效
# YES,默认值,禁止文件中的用户登录,同时也不向这些用户发出输入密码的提示。NO,只允许在文件中的用户登录FTP服务器
userlist_deny=NO
# 所有用户的根目录(对匿名用户无效)
local_root=/sharedata
#新增ftp用户并为其设置密码
$ useradd ftpuser -s /sbin/nologin
$ passwd ftpuser
#编辑user_list文件,给予ftpuser用户访问ftp权限
$ vim /etc/vsftpd/user_list
在文件末尾加入 ftpuser 并保存
#建立可访问目录并指定用户
$ mkdir -p /sharedata
$ chown -R ftpuser /sharedata
$ chmod -R 755 /sharedata
#启动vsftpd服务
$ systemctl start vsftpd.service
问题1:
Response: 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
Error: Critical error: Could not connect to server
解决:在vsftpd.conf配置文件中新增以下配置项
allow_writeable_chroot=YES
问题2:
Command:PASV
Response: 227 Entering Passive Mode (172,17,0,2,228,167).
Command:LIST
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
解决:
ftp> passive
Passive mode off.