Source: Internet
Author: User
Tags crypt ftp client

First, the installation of the necessary procedures

1. Install MySQL and pam_mysql

# yum-y Install vsftpd mysql-server mysql-devel pam_mysql

Note: Pam_mysql is provided by the Epel source.

Second, create a virtual user account

1. Prepare the database and related tables

First, 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.test.com ';

Mysql> Grant Select on vsftpd.* to [e-mail protected] identified by ' www.test.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 user

To 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 (' test '));

mysql> INSERT into users (Name,password) VALUES (' Jerry ', password (' test '));

Third, configuration vsftpd

1. Establish the required files for PAM Certification


Add the following two lines

Auth required/lib/security/pam_mysql.so user=vsftpd passwd=www.test.com host=localhost db=vsftpd table=users Usercolumn=name Passwdcolumn=password crypt=0

Account required/lib/security/pam_mysql.so user=vsftpd passwd=www.test.com host=localhost db=vsftpd table=users Usercolumn=name Passwdcolumn=password crypt=0

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 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







Then add the following options



And make sure that the value of the Pam_service_name option is as follows


Iv. Start VSFTPD Service

# service VSFTPD Start

# Chkconfig VSFTPD on

Viewing port opening conditions

# NETSTAT-TNLP |grep:21

TCP 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


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 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.





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.