RH EL5 VSFTPD virtual account (MySQL)

Source: Internet
Author: User
Tags crypt md5 hash

Platform: Red Hat RHEL5 + VSFTPD + MySQL

1. Install MySQL

Mysql-5.1.7-beta-linux-i686-glibc23.tar.gz
# Tar zxvf mysql-5.1.7-beta-linux-i686-glibc23.tar.gz
# Ln-s mysql-5.1.7-beta-linux-i686-glibc23/usr/local/mysql
# Cd/usr/local/mysql
# Scripts/mysql_install_db -- user = mysql
# Chown-R root.
# Chown-R mysql data
# Chgrp-R mysql.
# Bin/mysqld_safe &
# Bin/mysql
Mysql>

Ii. Install pam_mysql.so

Pam_mysql-0.7RC1.tar.gz //: chinaunix
# Tar zxvf pam_mysql-0.7RC1.tar.gz
# Cd pam_mysql-0.7RC1
#./Configure -- with-mysql =/usr/local/mysql
# Make clean install
# Cp/usr/lib/security/pam_mysql.so/lib/security/

3. Install vsftpd

Use rpm to install the vsftpd rpm package that comes with EL5.

4. Create a virtual user

# Useradd-d/home/vftp-s/bin/nologin vftp-m

5. Establish Authentication

Create a user using mysql
Put the user name and password in the mysql library, and the implementation is quite simple.
(1) Create a database and set the corresponding Permissions
# Mysql-p
Mysql> create database ftpd;
Mysql> use ftpd;
Mysql> create table user (name char (20) binary, passwd char (20) binary );
Mysql> insert into user (name, passwd) values ('Mike ', '123 ');
Mysql> insert into user (name, passwd) values ('Tom ', '123 ');
Mysql> grant select, insert on ftpd. user to vftp @ localhost identified by '123 ';
Mysql> flush privileges; refresh permission settings
Mysql> quit
(2) create PAM Authentication Information
# Vi/etc/pam. d/vftp. The content is as follows:
Auth required/lib/security/pam_mysql.so user = vftp passwd = 123 host = localhost db = ftpd table = user usercolumn = name passwdcolumn = passwd crypt = 0
Account required/lib/security/pam_mysql.so user = vftp passwd = 123 host = localhost db = ftpd table = user usercolumn = name passwdcolumn = passwd crypt = 0
Note:
Crypt = n
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.

6. Modify the ftp configuration file

Vi/etc/vsftpd. conf
Pam_service_name = vftp
Guest_enable = YES
Guest_username = vftp

VII. Verification

Log on to ftp as mike and tom

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.