1. Add Virtual user list
Create a virtual user list file, save the virtual account you want to configure, in the form of the first line user name, the second line password, and so on.
# vi/etc/vsftpd/virtual_user_list
ftp_www
123456
ftp_log
123456
2, the generation of virtual user password Authentication file
Generate the authentication file through the Db_load command. Query whether the Db_load command is installed or not, install it first.
# RPM-QA |grep db4-utils
local CentOS not installed, directly through the Yum installation can be.
# yum-y Install Db4-utils
Converts the previously added virtual_user_list virtual user password file into a system-recognized password Authentication file. After that, if you need to adjust the file, you need to perform the db_load action again.
# db_load-t-T hash-f/etc/vsftpd/virtual_user_list/etc/vsftpd/virtual_user_list.db
3. Set the PAM profile required by the virtual user
The Pam_service_name parameter in vsftpd.conf can specify a configuration file. This modifies the default vsftpd file.
# vi/etc/pam.d/vsftpd
# comment out the other parts
auth required/lib/security/pam_userdb.so db=/etc/vsftpd/virtual_user_ List account
required/lib/security/pam_userdb.so db=/etc/vsftpd/virtual_user_list
4. Create VSFTPD Hosting account number
# Useradd Vsftpd-s/sbin/nologin
5. Edit vsftpd.conf configuration file
Edit the Vsftp configuration file to add the virtual user related configuration.
# vi/etc/vsftpd/vsftpd.conf
# Settings enable virtual user functionality.
Guest_enable=yes
# Specifies the host user of the virtual user, the VSFTPD user created earlier.
guest_username=vsftpd
# Set the permissions of the virtual users to meet their host users.
Virtual_use_local_privs=yes
# Set the configuration file store path for the virtual user's personal vsftp. The configuration file must have the same name as the virtual user
# such as/etc/vsftpd/vconf/ftp_www can define the special configuration of the ftp_www.
user_config_dir=/etc/vsftpd/vconf
6, according to the virtual user set different permissions
Set Ftp_www can only access/data/ftp/www,ftp_log only Fann/data/ftp/log, create the required file and configuration information.
# mkdir -p /data/ftp/{www,log} # chown -r vsftpd:vsftpd /data/ftp/* # touch /etc/vsftpd/chroot_list # mkdir /etc/vsftpd/vconf # vi /etc/vsftpd/ Vconf/ftp_www local_root=/data/ftp/www Max_clients=1 max_per_ip=1 local_max_rate=10000 # vi /etc/ Vsftpd/vconf/ftp_log Local_root=/data/ftp/log 7, restart service # service vsftpd restart at this time the entire configuration file is as follows: # more vsftpd.conf anonymous_enable=no local_enable=yes write_enable=yes local_umask=022 anon_upload_ Enable=no anon_mkdir_write_enable=no dirmessage_enable=yes xferlog_enable=yes connect_from_port_20=yes #chown_ Uploads=yes #chown_username =whoever #xferlog_file =/var/log/xferlog xferlog_std_format=yes #idle_session_timeout = #data_connection_timeout =120 #nopriv_user =ftpsecure #async_abor_enable =yes #ascii_upload_enable =yes #ascii_
Download_enable=yes #ftpd_banner =welcome to blah ftp service. #deny_email_enable =yes #bAnned_email_file=/etc/vsftpd/banned_emails Chroot_list_enable=yes chroot_list_file=/etc/vsftpd/chroot_list chroot _local_user=yes #ls_recurse_enable =yes listen=yes #listen_ipv6 =yes PAM_SERVICE_NAME=VSFTPD userlist_enable= YES tcp_wrappers=yes Guest_enable=yes guest_username=vsftpd virtual_use_local_privs=yes user_config_dir=/etc/ Vsftpd/vconf