1.安装vsftpd
yum install -y vsftpd
systemctl enable vsftpd.service
service vsftpd restart
systemctl status vsftpd.service
2.配置vsftpd.conf文件
cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
sed -i "s/anonymous_enable=YES/anonymous_enable=NO/g" '/etc/vsftpd/vsftpd.conf'
sed -i "s/#anon_upload_enable=YES/anon_upload_enable=NO/g" '/etc/vsftpd/vsftpd.conf'
sed -i "s/#anon_mkdir_write_enable=YES/anon_mkdir_write_enable=YES/g" '/etc/vsftpd/vsftpd.conf'
sed -i "s/#chown_uploads=YES/chown_uploads=NO/g" '/etc/vsftpd/vsftpd.conf'
sed -i "s/#async_abor_enable=YES/async_abor_enable=YES/g" '/etc/vsftpd/vsftpd.conf'
sed -i "s/#ascii_upload_enable=YES/ascii_upload_enable=YES/g" '/etc/vsftpd/vsftpd.conf'
sed -i "s/#ascii_download_enable=YES/ascii_download_enable=YES/g" '/etc/vsftpd/vsftpd.conf'
sed -i "s/#ftpd_banner=Welcome to blah FTP service./ftpd_banner=Welcome to FTP service./g" '/etc/vsftpd/vsftpd.conf'
use_localtime=YES
listen_port=21
chroot_local_user=YES
idle_session_timeout=300
guest_enable=YES
guest_username=vsftpd
user_config_dir=/etc/vsftpd/vconf
data_connection_timeout=1
virtual_use_local_privs=YES
pasv_min_port=10060
pasv_max_port=10090
accept_timeout=5
connect_timeout=1
allow_writeable_chroot=YES
3.建立用户文件
vi /etc/vsftpd/virtusers
4.生成用户数据文件
db_load -T -t hash -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db
chmod 600 /etc/vsftpd/virtusers.db
5.修改/etc/pam.d/vsftpd文件
cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers
account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers
6.新建系统用户vsftpd,用户目录为/home/vsftpd
useradd vsftpd -d /home/vsftpd -s /bin/false
chown -R vsftpd:vsftpd /home/vsftpd
7.建立虚拟用户个人配置文件
mkdir /etc/vsftpd/vconf
cd /etc/vsftpd/vconf/
touch chrishi guest
mkdir -p /home/vsftpd/chrishi
vim chrishi
local_root=/home/vsftpd/chrishi/
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
8.防火墙设置
systemctl status firewalld.service
firewall-cmd --zone=public --add-port=80/tcp --permanent
9.重启vsftpd服务
systemctl restart vsftpd.service