centos7的ftp虚拟用户登录
1.安装vsftpd服务
yum -y install vsftpd
2.创建系统用户
useradd -d /home/hello -s /sbin/nologin hello
登陆的虚拟用户将以该用户的身份对目录进行操作
3.创建虚拟用户
vi /etc/vsftpd/vuser.list
添加:
world
redhat
创建虚拟用户主目录
mkdir /home/hello/world
chown hello:hello /home/hello/world
4.根据这个文件创建数据库文件
db_load -T -t hash -f /etc/vsftpd/vuser.list /etc/vsftpd/vuser.db
chmod 600 /etc/vsftpd/vuser.*
5.启用这个数据库文件
vi /etc/pam.d/vsftpd
注释掉所有条目然后增加:
auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser
account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser
6.创建虚拟用户配置文件
mkdir /etc/vsftpd/userconf
vi /etc/vsftpd/userconf/world
添加:
anon_upload_enable=YES
anon_mkdir_write_enable=YESwrite_enable=YESanon_world_readable_only=NOanon_other_write_enable=YESanon_umask=022local_root=/home/hello/world/ (设定主目录为/home/hello/world)7.修改主配置文件
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
chroot_local_user=YES
ascii_upload_enable=YES
ascii_download_enable=YES
pasv_min_port=10000
pasv_max_port=10020
guest_enable=YES
guest_username=hello
user_config_dir=/etc/vsftpd/userconf
allow_writeable_chroot=YES(最新版的vsftpd为了安全必须用户主目录(也就是/home/hello/world/)没有写权限,才能登录,或者使用allow_writeable_chroot=YES)
重启 systemctl restart vsftpd
搭建ok
关闭防火墙和selinux
systemctl stop firewalld
setenforce 0
如果想上传文件,删除文件,创建文件。可添加以下参数到/etc/vsftpd/vsftpd.conf

浙公网安备 33010602011771号