Ftp+mysql Virtual Users

Source: Internet
Author: User

Virtual User:

The so-called virtual user, that is, all virtual users will be unified mapping to a designated system account, access to the shared location is the home directory for this system account. Very easy to manage.

Experiment Title: Ftp+mysql

Experimental Purpose: Virtual users in the MySQL table, the remote way to achieve the management of virtual users control

Experimental topology:

650) this.width=650; "title=" @y$zn969 ' 6nz6otuqs (9}qe.jpg "alt=" wkiom1qlleawgioxaacuezby9ik095.jpg "src=" http:/ S3.51cto.com/wyfs02/m02/48/bb/wkiom1qlleawgioxaacuezby9ik095.jpg "/>

Description: The two servers can be crafted into one, where two is implemented to enable FTP to achieve administrative control over the network and MySQL, and this can be seen more intuitively.

1. Install MySQL (192.168.0.3)

Can be installed with Yum, you can also compile the installation, already described in the previous MySQL installation, there is no longer a demonstration

Install FTP server and Pam_mysql, this package needs to be downloaded online (192.168.0.2)

#yum Install VSFTPD Pam_mysql

2. 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] ' 192.168.%.% ' identified by ' www.ky.com ';mysql> flush Privileges ;

Test if you can connect to the MySQL database on the FTP server. This one was tested on the 192.168.0.2.

650) this.width=650; "Title=" 20~@3cajwb~hcht ((fvvl}v.jpg "alt=" wkiol1qlly7t4mxwaagbfl3gxai779.jpg "src=" http:/ S3.51cto.com/wyfs02/m01/48/bd/wkiol1qlly7t4mxwaagbfl3gxai779.jpg "/>

3. CREATE table structure, add data (virtual user's account and password)

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> use vsftpd;mysql> CREATE TABLE users (with ID int auto_increment not NULL, name char) binary     Not NULL, password char (n) binary NOT NULL, PRIMARY key (ID). mysql> INSERT into users (Name,password) VALUES (' Vstom ', password (' www.ky.com '));mysql> insert into users (name, Password) VALUES (' Vsjerry ', password (' www.ky.com '));

650) this.width=650; "title=" UPB) nwitzsqx (jr[oc5y${n.jpg "alt=" wkiol1qlmlrxwtqraadayfomfzi136.jpg "src="/HTTP/ S3.51cto.com/wyfs02/m00/48/bd/wkiol1qlmlrxwtqraadayfomfzi136.jpg "/>

4. Configure VSFTPD

Establish the required files for PAM Certification

See where pam_mysql.so is placed

650) this.width=650; "title=" H3y~pgj$r ' 2[e3[2ak8chvf.jpg "alt=" wkiom1qlmsfik7vsaaflp72jtuw527.jpg "src=" http:/ S3.51cto.com/wyfs02/m00/48/bb/wkiom1qlmsfik7vsaaflp72jtuw527.jpg "/>

#vi/etc/pam.d/vsftpd.mysql

Add the following two lines

650) this.width=650; "Title=" v@z~~ (uvsmc018y ' pni]i7y.jpg "alt=" wkiol1qlmybtwusyaad2qnw5jyq447.jpg "src=" http:/ S3.51cto.com/wyfs02/m01/48/bd/wkiol1qlmybtwusyaad2qnw5jyq447.jpg "/>

Detailed

User: Remote connection to MySQL username

Password: remote connection to MySQL password

Host: Server address for remote connection to MySQL

DB: Database name of the connection

Table: The names of tables in the connected database

Usercolumn: Field names in a table

Passwdcolumn: Name of the password field in the table

Crypt: Password encrypted by this method

0: No encryption. Passwords are stored in plain text

1: Using the Crypt (3) function

2: Use MySQL password

3: Using MD5 encryption

4: Using SHA encryption

5. 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/bin/nologin-d/var/vftp kyfish# chmod go+rx/var/vftp

Make sure that the following options are enabled in/etc/vsftpd.conf

Anonymous_enable=yeslocal_enable=yeswrite_enable=yesanon_upload_enable=noanon_mkdir_write_enable=nochroot_ Local_user=yes

Then add the following options

Guest_enable=yesguest_username=kyfish mapping guest users to kyfish users

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

Pam_service_name=vsftpd.mysql

Testing with Windows

650) this.width=650; "title=" A ' 7TFI ' 1_x6}~ (ufs6h2a2v.jpg "alt=" wkiom1qlnj-sydnraab-mgo93og271.jpg "src="/HTTP/ S3.51cto.com/wyfs02/m02/48/bb/wkiom1qlnj-sydnraab-mgo93og271.jpg "/>

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

Configure VSFTPD to use the profile directory for virtual users

# Vim Vsftpd.conf

Add the following options

User_config_dir=/etc/vsftpd/vusers

Create the required directory and provide the configuration file for the virtual user

# mkdir/etc/vsftpd/vusers# cd/etc/vsftpd/vusers# Touch Vstom Vsjerry

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 manage the permissions of the Vstom user, you can modify the/etc/vsftpd/vusers/vstom file and add the following options.

Local_root=/var/vftp/vstom Specify the virtual user's own home directory Write_enable=yesanon_enable=yesanon_mkdir_write_enable=yesanon_other_ Write_enable=no

So the Ftp+mysql experiment was successful.

This article is from the "Fish" blog, please be sure to keep this source http://kyfish.blog.51cto.com/1570421/1549716

Ftp+mysql Virtual Users

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.