Vsftp server setup-MySQL authentication for virtual users

Source: Internet
Author: User
Tags crypt md5 hash

1. Install MySQL using yum
# Yum-y install mysql-servermysql-devel
2. Start the MySQL service and modify the MySQL administrator password.
# Service mysqldstart
# Mysql_secure_installation // set the root administrator password
3. Create a MySQL database and Table For vsftpd Verification
[Root @ vsftpd ~] # Mysql-u root-p
Enter password: // Enter vsftpd as the administrator password just set for MySQL.


Mysql> create database vsftpd; // create a vsftpd database
Query OK, 1 rowaffected (0.00 sec)
Mysql> use vsftpd; // use the vsftpd Database
Mysql> create table users (
> Id int not null AUTO_INCREMENT PRIMARYKEY,
> Name CHAR (15) not null unique key,
> PasswordCHAR (48) not null); // create a users table with three columns, an id for indexing, name for account name, and password for setting the password
Mysql> insert into users (name, password) values ('oracle ', password ('oracle'); // Add an Oracle account, the password is oracle, and the storage password is encrypted, this account is used to log on to the FTP server.
4. Create a MySQL account For vsftpd to retrieve the vsftpd database.
Mysql> grant select on vsftpd. * to vsftpd @ localhostidentified by 'vsftpd '; // create a MySQL account that has only the permission to all tables in the select vsftpd database and set the password to vsftpd
Mysql> flush privileges; // only for the permission to take effect immediately
Ii. install and configure the PAM module
1. Install the dependency Library
[Root @ vsftpd ~] # Yum-y install gccgcc-c ++ make pam-devel openssl-devel
2. Download and install pam_mysql
[Root @ vsftpd ~] # Wget http://nchc.dl.sourceforge.net/project/pam-mysql/pam-mysql/0.7RC1/pam_mysql-0.7RC1.tar.gz
[Root @ vsftpd ~] # Tar zxvf pam_mysql-0.7RC1.tar.gz
[Root @ vsftpd ~] # Cd pam_mysql-0.7RC1
[Root@vsftpdpam_mysql-0.7RC1] #./configure -- with-openssl
# Make
[Root @ vsftpd pam_mysql-0.7RC1] # make install
The pam file is installed in the/lib directory by default. if the system is a 64-bit system, copy the file to the/lib64 directory.
[Root @ vsftpd ~] # Cp/lib/security/pam_mysql. */lib64/security/


3. Create an authentication File
[Root @ vsftpd ~] # Vim/etc/pam. d/vsftpd. mysql
Auth required/lib64/security/pam_mysql.souser = vsftpd passwd = vsftpd host = localhost db = vsftpd table = users usercolumn = namepasswdcolumn = password crypt = 2
Account required/lib64/security/pam_mysql.so user = vsftpd passwd = vsftpd host = localhost db = vsftpdtable = users usercolumn = name passwdcolumn = password crypt = 2
Note: There are two rows. line breaks are not allowed. In addition, you must enter the corresponding fields in the column.
Special instructions on crypt options
Crypt = 0: plaintext Password
Crypt = 1: Use the crpyt () function (corresponding to encrypt () in SQL data, encrypt () to randomly generate salt)
Crypt = 2: Use the password () function in MYSQL to encrypt data.
Crypt = 3: Indicates md5 hash.
User and passwd username and password can also be set at will, but you need to grant the query permission in mysql.

Recommended reading:

Four Advanced configurations of vsftpd Server:

VsFTPd configuration Tutorial:

Simple and practical Ubuntu FTP setup

Set up FTP server and Apache server on Ubuntu

Install the LAMP \ vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04

Simple case of anonymous uploading of SeLinux and vsftpd on the RHEL6 Platform

Install vsftpd source code in Linux

Case study of vsftpd Security Configuration

  • 1
  • 2
  • Next Page

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.