First, the installation of the necessary procedures
Install the development environment and MySQL database in advance.
#yum-y Install mysql-server mysql-devel
#yum-y Install Groupinstall "Development Tools" "Development Libraries"
Installing PAM_MYSQL-0.7RC1
#tar ZXVF pam_mysql-0.7rc1.tar.gz
#cd Pam_mysql-0.7rc1
#./configure--with-mysql=/usr--with-openssl
#make
#make Install
Installing VSFTP
#yum-y Install vsftpd
Second, create a virtual user account
Prepare database and related tables
First, make sure that the MySQL service is up and running. Then, build the database that stores the virtual user as needed, and create it as a VSFTPD database
mysql>create databases vsftpd;
Mysql>grant Select on vsftpd.* to [e-mail protected] identified by ' password ';
Mysql>grant Select on vsftpd.* to [e-mail protected] identified by ' password ';
Mysql>flush privileges;
Mysql>use vsftpd;
Mysql>create table users (id int auto_increment not NULL,
->name char () binary not NULL,
->password char () binary not NULL,
->primary key (ID));
2. Adding a Test virtual user
To add the required users as needed, it should be explained that the password is stored in plaintext format because the pam_mysql password () function and the MySQL password () function may be different.
Mysql>insert into users (Name,password) VALUES (' Tom ', ' Passwd1 ');
Mysql>insert into users (Name,password) VALUES (' Jerry ', ' Passwd2 ');
Third, configuration vsftpd
1. Establish the required files for PAM Certification
#vi/etc/pam.d/vsftpd.mysql
Add the following two lines
Auth required/lib/security/pam_mysql.so user=vsftpd passwd= password host=localhost db=vsftpd table=users usercolumn=name Passwdcolumn=password crypt=0
Account required/lib/security/pam_mysql.so user=vsftpd passwd= password host=localhost db=vsftpd table=users usercolumn=name Passwdcolumn=password crypt=0
2. Modify the VSFTPD configuration file to adapt it to MySQL authentication
Establish a virtual user mapping of the system users and corresponding directories
#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
Local_enable=yes
Write_enable=yes
Anon_upload_enable=no
Anon_mkdir_write_enable=no
Chroot_local_user=yes
Then add the following options
Guest_enable=yes
Guest_username=vuser
And make sure that the value of the Pam_service_name option is as follows
Pam_service_name=vsftpd.mysql
Iv. Start VSFTPD Service
# service VSFTPD Start
# Chkconfig VSFTPD on
Viewing port opening conditions
# NETSTAT-TNLP |grep:21
TCP 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 23286/vsftpd
Using the virtual user login, positive configuration results, the following is the local command mode test, you can also use the other win box with IE or FTP client tool login
# FTP localhost
V. Configure virtual users to have different access rights
VSFTPD can provide each user with a separate profile in the profile directory to define their FTP service access rights, with each virtual user's profile name and the virtual user's user name. The configuration file directory can be any unused directory, just specify its path and name in vsftpd.conf.
1. Configure VSFTPD to use the profile directory for virtual users
# Vim Vsftpd.conf
Add the following options
User_config_dir=/etc/vsftpd/vusers_dir
2. Create the required directory and provide the configuration file for the virtual user
# mkdir/etc/vsftpd/vusers_dir/
# cd/etc/vsftpd/vusers_dir/
# Touch Tom Jerry
3. Configure access rights for virtual users
The 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/tom file, add the following options.
Anon_upload_enable=yes
Vsftp Pam MySQL