1. Install vsftpd
#安装vsftpd
Yum install-y vsftpd
#设置开机启动
systemctl enable vsftpd.service
# restart
service vsftpd Restart
# View the status of the VSFTPD service
systemctl status Vsftpd.service
2. Configure 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 ' Add the following to the end of 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
3. Create user files
#第一行用户名, second line password, cannot use root for user name
vi/etc/vsftpd/virtusers
Chris
123456
Chang
123456
4. Generate User Data Files
Db_load-t-T hash-f/etc/vsftpd/virtusers/etc/vsftpd/virtusers.db
#设定PAM验证文件 and specifies that the virtual user database file be read
5. Modify the/etc/pam.d/vsftpd file
# Back up Cp/etc/pam.d/vsftpd/etc/pam.d/vsftpd.bak before
you modify auth and account all configuration lines are commented out
vi/etc/pam.d/vsftpd
auth sufficient/lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers account
sufficient/lib64/ security/pam_userdb.so db=/etc/vsftpd/virtusers
# If the system is 32 bits, the above is changed to Lib
6. New System user vsftpd, User directory is/home/vsftpd
#用户登录终端设为/bin/false (ie: make it unable to log on to the system)
useradd vsftpd-d/home/vsftpd-s/bin/false chown-r
Vsftpd
7. Create a personal profile for a virtual user
mkdir/etc/vsftpd/vconf
cd/etc/vsftpd/vconf
#这里建立两个虚拟用户配合文件 touch
Chris Chang
#建立用户根目录
mkdir- p/home/vsftpd/chris/
#编辑chris用户配置文件, the content is as follows, other users like
vi Chris
local_root=/home/vsftpd/chris/
Write_ Enable=yes
anon_world_readable_only=no
anon_upload_enable=yes
anon_mkdir_write_enable=yes
Anon_other_write_enable=yes
8. Firewall Settings
Vi/etc/sysconfig/iptables
#编辑iptables文件, add the following to open port 21
-A input-m State--state new-m tcp-p TCP--dport 21-j ACCEPT
9. Restart VSFTPD Server
Service VSFTPD Restart
10. Use xftp and other software connection test