环境:​centos 7

yum安装

yum install -y vsftpd


增加用户

# 家目录为/www 并设置nologin
useradd -d /www -s /sbin/nologin /www
# 修改密码
passwd www


配置(/etc/vsftpd/vsftpd.conf)

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
ascii_upload_enable=YES
ascii_download_enable=YES
chroot_local_user=YES
listen=YES
listen_ipv6=NO

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
allow_writeable_chroot=YES


启动服务

systemctl start vsftpd

# 设置开机启动
systemctl enable vsftpd



遇到错误 - 1

  530 Login incorrect.

  记linux vsftpd配置遇到的错误_编辑文件

   解决方案

  编辑文件 ​/etc/pam.d/vsftpd

#%PAM-1.0S
session optional pam_keyinit.so force revoke
auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
# 注释这行
#auth required pam_shells.so
auth include password-auth
account include password-auth
session required pam_loginuid.so
session include password-auth



遇到错误 - 2

  ​500 OOPS: vsftpd: refusing to run with writable root inside chroot()

  记linux vsftpd配置遇到的错误_开机启动_02



   解决方案

  编辑文件 ​/etc/vsftpd/vsftpd.conf

# 增加该行
allow_writeable_chroot=YES