Centos使用vsftpd搭建ftp环境

下载ftp

yum -y install vsftpd

编辑配置文件,将下面两项的注释打开

# vim /etc/vsftpd/vsftpd.conf

chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list # 允许登录服务器的账号列表文件
allow_writeable_chroot=YES # 解决500 OOPS: vsftpd: refusing to run with writable root inside chroot() 错误

编辑pam鉴权文件,注释掉pam_shells.so这一项

# vim /etc/pam.d/vsftpd

# auth       required    pam_shells.so

启动服务

systemctl start vsftpd

配置服务开机自启动(可选)

chkconfig vsftpd on

新建用户,并指定他所能查看的目录范围(-d)同时限制该用户使用终端登录(-s)

useradd -d /home/www -s /sbin/nologin userName

初始化该用户的密码

(PS: 设置密码的时候可能会提示”无效的密码: 密码未通过字典检查 - 它没有包含足够的不同字符“,忽略提示即可)

passwd userName

把该用户添加到 chroot_list

# vim /etc/vsftpd/chroot_list

userName # 这里填写自己添加的用户名
posted @ 2021-08-13 16:42  GetcharZp  阅读(72)  评论(0编辑  收藏  举报