Configuration Description:
1. mysql server: CentOS6.6 192.168.1.62
2, VSFTPD server: CentOS6.6 192.168.1.61
First, configure the MySQL server
1. Install MySQL
[[email protected] ~]# yum-y install mysql-server[[email protected] ~]# service mysqld start[[email protected] ~]# MySQL
2. Prepare database and related tables
mysql> CREATE DATABASE vsftpd; Query OK, 1 row Affected (0.00 sec) mysql> Grant Select on vsftpd.* to [e-mail protected] identified by ' 123456 '; Query OK, 0 rows Affected (0.00 sec) mysql> Flush privileges;mysql> CREATE TABLE users (id int auto_increment not nu ll, name char (a) binary NOT null, password char (n) binary NOT NULL, PRIMARY key (ID)); Query OK, 0 rows affected (0.08 sec)
2. Add test User
mysql> INSERT into users (Name,password) VALUES (' Zhangsan ', password (' 123456 ')); Query OK, 1 row Affected (0.00 sec) mysql> insert into users (Name,password) VALUES (' Lisi ', password (' 123456 ')); Query OK, 1 row Affected (0.00 sec)
Second, the configuration vsftpd
1. Install Epel source
[Email protected] ~]# RPM-IVH http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm
2, installation VSFTPD service and PAM_MYSQL certification
[Email protected] ~]# yum-y install vsftpd pam_mysql
3, the establishment of PAM certification required documents
# Vim/etc/pam.d/vsftpd.mysqlauth Required pam_mysql.so user=vsftpd passwd=123456 host=192.168.1.62 db=vsftpd table= Users usercolumn=name Passwdcolumn=password crypt=2account required pam_mysql.so user=vsftpd passwd=123456 host= 192.168.1.62 db=vsftpd table=users usercolumn=name Passwdcolumn=password crypt=2
4, add the virtual user corresponding system user, make it suitable for MySQL authentication
[Email protected] ~]# useradd-s/sbin/nologin-d/var/ftproot vuser[[email protected] ~]# chmod +rx/var/ftproot/
5, Modify the vsftpd configuration file
Make sure that the following options are enabled in/etc/vsftpd.conf Anonymous_enable=nolocal_enable=yeswrite_enable=yesanon_upload_enable=noanon_ Mkdir_write_enable=nochroot_local_user=yes then add the following options Guest_enable=yesguest_username=vuser and make sure Pam_service_ The value of the name option is as follows Pam_service_name=vsftpd.mysql
6. Restart the service and verify
[Email protected] vsftpd]# service vsftpd restart
Third, configure the virtual user with 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_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 Zhangsan Lisi
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_config/tom file, add the following options.
Anon_upload_enable={yes|no}
Anon_mkdir_write_enable={yes|no}
Anon_other_write_enable={yes|no}
This article is from the "Chase Dream" blog, please be sure to keep this source http://387227.blog.51cto.com/377227/1831845
Configuring the FTP server with MySQL authentication