first, the installation of the necessary proceduresYum Install vsftpd mysql-server mysql-devel pam_mysqlSecond, create a virtual user account
1. Prepare database and related tablesfirst, make sure that the MySQL service is up and running. Then, create the database that stores the virtual users as needed, which is created as a VSFTPD database. mysql> CREATE database vsftpd;
mysql> Grant Select on vsftpd.* to [e-mail protected] identified by ' www.magedu.com ';==> need to communicate via UNIX socketsmysql> Grant Select on vsftpd.* to [e-mail protected] identified by ' www.magedu.com '; mysql> flush Privileges;
mysql> use vsftpd;mysql> CREATE TABLE users (-ID int auto_increment not NULL,, Name char (a) binary not NULL,password char () binary not NULL,-primary KEY (ID));
2. Adding a test virtual userTo add the required users as needed, it is necessary to note that their passwords should be stored with the password function encrypted for security purposes. mysql> INSERT into users (Name,password) VALUES (' Tom ', password (' magedu '));
mysql> INSERT into users (Name,password) VALUES (' Jerry ', password (' magedu '));3, configuration vsftpd
1. Create the required files for PAM certification# RPM-QL Pam_mysql==> ViewPam_mysql Installing the generated files
# Less/usr/share/doc/pam_mysql-0.7/readme==>Pam_mysql Help Documentation
# Vim/etc/pam.d/vsftpd.mysql==> New Pam file and add the following:auth required/lib64/security/pam_mysql.so user=vsftpd passwd=vsftpd host=127.0.0.1 db=vsftpd table=users Usercolumn=name Passwdcolumn=password crypt=2Account required/lib64/security/pam_mysql.so user=vsftpd passwd=vsftpd host=127.0.0.1 db=vsftpd table=users Usercolumn=name Passwdcolumn=password crypt=2
Note: Due to the way MySQL is installed, pam_mysql.so Unix-based sock may have problems connecting to the MySQL server , and it is recommended that you authorize a remotely connected MySQL user to access the VSFTPD database.
2, modify the Vsftpds configuration file, make it adapt to MySQL authentication
system users and corresponding directories for establishing virtual user mappings# useradd-s/sbin/nologin-d/var/ftproot vuser# chmod Go+rx/var/ftproot
Make sure that the following options are enabled in/etc/vsftpd.conf
Anonymous_enable=yes==> Allow anonymous user accessLocal_enable=yes==>set the local user to be accessible. Note: Primarily for virtual hosting users, if the item is set to No then all virtual users will not be able to accessWrite_enable=yes==> Allow WriteAnon_upload_enable=no==> anonymous users cannot uploadAnon_mkdir_write_enable=no==> Anonymous users cannot create and writeChroot_local_user=yes==> restricted to the user's home directory
then add the following options
Guest_enable=yesGuest_username=vuser ==> All Guest accounts mapped to Vusers
and make sure that the value of the Pam_service_name option is as followsPam_service_name=vsftpd.mysql4. Enable VSFTPD# service VSFTPD start# chkconfig VSFTPD onviewing port opening conditions
If you have any questions,Viewing the error log# tail/var/log/secure
5. Configure access rights for virtual usersThe virtual user's access to the VSFTPD service is done through the instructions of the anonymous user. For example, if you need to let Tom users have permission to upload files, you can modify the/etc/vsftpd/vusers_config/tom file, add the following options.
1. Configure VSFTPD to use profile directory for virtual users # vim vsftpd.conf
Add the following options User_config_dir=/etc/vsftpd/vusers_config
2. Create the required directory and provide the configuration file for the virtual user
# mkdir/etc/vsftpd/vusers_config/
# cd/etc/vsftpd/vusers_config/# Touch Tom Jerry
3. Configure access rights for virtual users the access rights of the virtual user to the VSFTPD service are made by the relevant instructions of the anonymous user. For example, if you need to let Tom users have permission to upload files, you can modify the/etc/vsftpd/vusers_config/tom file, add the following options. (Can get more permissions with man vsftp.conf)
Anon_upload_enable={yes|no}==> uploading and creating permissionsAnon_mkdir_write_enable={yes|no}==> Anonymous User Establishment directoryAnon_other_write_enable={yes|no}==> Allow deletion and renamingLocal_root=/opt/vsftp/virtuser==>specifies the specific primary path of the virtual user. Anonymous_enable=no==>setting does not allow anonymous user access. Write_enable=yes==>set allow write operations. local_umask=022==>sets the upload file permission mask. idle_session_timeout=600==>Sets the idle connection timeout period. data_connection_timeout=120==>sets the maximum time for a single continuous transmission. max_clients=10==>sets the number of concurrent client accesses. max_per_ip=5==>set the maximum number of threads for a single client, this configuration is mainly to take care of flashget, thunder and other multi-threaded download softwarelocal_max_rate=50000==>set the maximum transfer rate for this user, Unit B/S
Vsftpd+pam+mysql