1.安装vsftp
yum install vsftpd
2.修改配置文件
vim /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_umask=022
dirmessage_enable=YES
dual_log_enable=YES
xferlog_enable=YES
connect_from_port_20=NO
xferlog_std_format=YES
pam_service_name=vsftpd
# This is a user whitelist we use
userlist_enable=YES
#userlist_deny=NO
#userlist_file=/etc/vsftpd/user_list
tcp_wrappers=YES
pasv_enable=YES
pasv_promiscuous=NO
port_enable=YES
port_promiscuous=NO
chroot_local_user=YES
chroot_list_enable=NO
allow_writeable_chroot=YES
guest_enable=YES
guest_username=ftp
user_config_dir=/etc/vsftpd/vconf/
listen=NO
listen_ipv6=YES
listen_port=2128
# These are the ports to use for PASV mode
# It is important that these port numbers are unique across each of your backend servers
pasv_min_port=20321
pasv_max_port=20340
3.创建匿名用户及密码
vim /etc/vsftpd/vuser.list
test #奇数为用户名
123456#偶数为密码
db_load -T -t hash -f /etc/vsftpd/vusers.list /etc/vsftpd/vusers.db
4.创建用户配置文件
mkdir /etc/vsftpd/vconf
vim /etc/vsftpd/vconf/test
local_root=/data/ftpserver/test #这里为用户上传后存放的目录
write_enable=yes
anon_world_readable_only=yes
anon_upload_enable=yes
anon_mkdir_write_enable=yes
anon_other_write_enable=yes
local_umask=022
download_enable=yes
5.创建用户上传后的目录
mkdir -p /data/ftpserver/test
6.修改认证
vim /etc/pam.d/vsftpd
#%PAM-1.0
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
#
##session optional pam_keyinit.so force revoke
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vusers
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vusers
7.重启服务
service vsftpd restart
8.添加一个新的用户
编辑vuser.list
vim /etc/vsfptd/vuser.list
test
123456
test1
123456
9.重新生成用户库
db_load -T -t hash -f /etc/vsftpd/vusers.list /etc/vsftpd/vusers.db
10.创建用户配置
vim /etc/vsftpd/vconf/test1
local_root=/data/ftpserver/test1 #这里为用户上传后存放的目录
write_enable=yes
anon_world_readable_only=yes
anon_upload_enable=yes
anon_mkdir_write_enable=yes
anon_other_write_enable=yes
local_umask=022
download_enable=yes
11.创建用户上传后的目录
mkdir /data/ftpserver/test1