Preparations:
1. Create a security Directory
Mkdir-p/var/run/vsftpd/empty/
2. Create vsftpd users and directories, and authorize
Groupadd-g 6005 vsftpd
Useradd-c "vsftpd user"-g 6005-G vsftpd-u 6005-M vsftpd-s/sbin/nologin
Mkdir/home/vsftpd
Chown-R vsftpd: vsftpd/home/vsftpd
Ubuntu 12.04:
1. Install vsftpd and db4.8-util
Sudo add-apt-repository ppa: thefrontiergroup/vsftpd
Sudo apt-get update
Apt-get install vsftpd db4.8-util
2. Modify the vsftpd configuration file
Local_enable = YES
Anonymous_enable = NO
Anon_upload_enable = NO
Anon_other_write_enable = NO
Anon_mkdir_write_enable = NO
Ftpd_banner = Welcome to FtpServer
Listen = YES
Listen_port= 9999
Local_umask = 022
Write_enable = Yes
Connect_from_port_20 = YES
Nopriv_user = vsftpd
Tcp_wrappers = YES
Chroot_local_user = YES
Chroot_list_enable = YES
Chroot_list_file =/etc/chroot_list
Userlist_enable = YES
Userlist_deny = NO
Userlist_file =/etc/allow
Dual_log_enable = YES
Vsftpd_log_file =/var/log/vsftpd. log
Allow_writeable_chroot = YES
# Xferlog_enable = YES
# Xferlog_file =/etc/logs/xferlog
Pasv_enable = YES
Pasv_min_port = 50000
Pasvanderbilt max_port = 60000
Guest_enable = YES
Guest_username = vsftpd
Pam_service_name = vsftpd
Virtual_use_local_privs = YES
Use_localtime = YES
User_config_dir =/etc/vsftpd_user_conf
Secure_chroot_dir =/var/run/vsftpd/empty
Idle_session_timeout = 3600
Use the vsftpd command to test whether the configuration is feasible.
3. Create a virtual account
Vim vsftpd_useraccess.txt
Username and password of an odd row
Username
Passoword
Db4.8 _ load-T-t hash-f/etc/vsftpd_useraccess/etc/vsftpd_useraccess.db
Chmod 600/etc/vsftpd_useraccess.db
4. Configure the PAM file
Vim/etc/pam. d/vsftpd
Comment other content, add the following section
Auth required pam_userdb.so db =/etc/vsftpd_useraccess
Account required pam_userdb.so db =/etc/vsftpd_useraccess
5. Configure virtual users
Modify
Mkdir/etc/vsftpd_user_dir/
Vim username
Join
Local_root =/home/www/
Write_enable = YES
Local_umask = 022
Vim vsftpd_user_list
Join
Username
Centos:
1. Install vsftpd and db4.8-util
Yum-y install vsftpd db4-utils
2. Modify the vsftpd configuration file
Local_enable = YES
Anonymous_enable = NO
Anon_upload_enable = NO
Anon_other_write_enable = NO
Anon_mkdir_write_enable = NO
Ftpd_banner = Welcome to FtpServer
Listen = YES
Listen_port = 21
Local_umask = 022
Write_enable = Yes
Connect_from_port_20 = YES
Nopriv_user = vsftpd
Tcp_wrappers = YES
Chroot_local_user = YES
Chroot_list_enable = YES
Chroot_list_file =/etc/vsftpd/vsftpd_chroot_list
Userlist_enable = YES
Userlist_deny = NO
Userlist_file =/etc/vsftpd/vsftpd_user_list
Dual_log_enable = YES
Vsftpd_log_file =/var/log/vsftpd. log
Allow_writeable_chroot = YES
# Xferlog_enable = YES
# Xferlog_file =/etc/logs/xferlog
Pasv_enable = YES
Pasv_min_port = 50000
Pasvanderbilt max_port = 60000
Guest_enable = YES
Guest_username = ftp
Pam_service_name = vsftpd
Virtual_use_local_privs = YES
Use_localtime = YES
User_config_dir =/etc/vsftpd/vsftpd_user_dir
Secure_chroot_dir =/var/run/vsftpd/empty
Idle_session_timeout = 3600
Use the vsftpd command to test whether the configuration is feasible.
3. Create a virtual account
Vim vsftpd_useraccess.txt
Username and password of an odd row
Username
Passoword
Db_load-T-t hash-f/etc/vsftpd/vsftpd_useraccess/etc/vsftpd/vsftpd_useraccess.db
Chmod 600/etc/vsftpd/vsftpd_useraccess.db
4. Configure the PAM file
Vim/etc/pam. d/vsftpd
Comment other content, add the following section
Auth required pam_userdb.so db =/etc/vsftpd/vsftpd_useraccess
Account required pam_userdb.so db =/etc/vsftpd/vsftpd_useraccess
5. Configure virtual users
Mkdir/etc/vsftpd_user_dir/
Vim username
Join
Local_root =/home/www/
Write_enable = YES
Local_umask = 022
Vim vsftpd_user_list
Join
Username