1安装vsftp
yum install vsftpd -y
2安装db5
wget https://github.com/berkeleydb/libdb/releases/download/v5.3.28/db-5.3.28.tar.gz .
tar zxvf db-5.3.28.tar.gz
cd db-5.3.28/build_unix/
../dist/configure -prefix=/usr/local
Make
Make install
3建用户等
useradd vsftpd -s /sbin/nologin
touch /var/log/vsftpd.log
chown vsftpd.vsftpd /var/log/vsftpd.log
#创建虚拟用户
mkdir -p /etc/vsftpd/vconf
touch /etc/vsftpd/vconf/vir_user
vim /etc/vsftpd/vconf/vir_user
test1 //用户名
12345678 //密码
#注意:第一行用户名,第二行是上一行用户名的密码,以此类推
db_load -T -t hash -f /etc/vsftpd/vconf/vir_user /etc/vsftpd/vconf/vir_user.db
#注意每次添加或者删除一个用户时都要执行生成数据库,否则将无法登录访问,
mv /etc/vsftpd/vconf/vir_user.db /etc/vsftpd/vconf/vir_user.db.bak
db_load -T -t hash -f /etc/vsftpd/vconf/vir_user /etc/vsftpd/vconf/vir_user.db
chmod 600 /etc/vsftpd/vconf/vir_user.db
vim /etc/pam.d/vsftpd
#%PAM-1.0
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vconf/vir_user
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vconf/vir_user
4 创建用户的配置文件,注意,用户配置文件的名字要和创建的“虚拟用户”名字对应
touch /etc/vsftpd/vconf/test1
vim /etc/vsftpd/vconf/test1
local_root=/home/ftp
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
allow_writeable_chroot=YES
mkdir -p /home/ftp
chown vsftpd.vsftpd -R /home/ftp/
5修改配置vim /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
idle_session_timeout=600
ftpd_banner=Welcome to MY FTP service.
chroot_local_user=YES
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
use_localtime=YES
listen_port=21
idle_session_timeout=300
data_connection_timeout=120
guest_enable=YES
guest_username=vsftpd
user_config_dir=/etc/vsftpd/vconf
virtual_use_local_privs=YES
pasv_min_port=10060
pasv_max_port=10090
accept_timeout=5
connect_timeout=1
6启动
systemctl enable vsftpd
systemctl start vsftpd