Implementing MySQL-based authentication for VSFTPD virtual users

Source: Internet
Author: User

FTP is a file transfer protocol, to implement this protocol, you need to install a number of appropriate services and tools. In the client needs to install the connection tool, our common Client Connection tool has Ftp,lftp,wget,curl, etc., on the server need to install some software packages, such as VSFTPD, so that the client and the server to achieve the connection. This experiment is to realize the VSFTPD virtual user based on MySQL authentication, the purpose of this experiment is to implement a secure file transfer protocol.

This experiment requires three virtual machines, one to do FTP server, one for the client, one to do the database.

Steps:

server-side :

  1. Installing the FTP Connection tool

    Yum Install vsftpd

  2. install some of the software packages required to connect to the database, if the virtual machine version is CENTOS6, you do not need to install it, because it comes with, it needs to be installed on the CENTOS7. In 7 there is no pam-mysql software, you need to download the official website, address http://pam-mysql.sourceforge.net/, after the corresponding version of the download can be.

    after downloading to compile the installation, here is the specific compilation steps:

    @1, unzip

    Span style= "font-size:18pt" >@2, installed dependent packages and package groups

    yum Groupinstall " Development tools "

    yum install mariadb-devel

    yum install pam-devel

    @3, check the configuration is complete under the extracted Pam package

     

    Span style= "font-size:18pt" >@4, if configuration is not a problem, compile and install

     

  3. Next, you configure the files on the server side to connect to the database, and only the files are configured to connect to the database. The file is created in the specified directory, and some configuration parameters are written in it.

    Cd/etc/pam.d

    Vim Vsftpd.mysql (the database name itself randomly)

    The above paragraph means that the user connected to the database is FTP, the password is CentOS, the host IP where the database is 192.168.37.101, the database name is VSFTPD, the data table is ftpusers, and so on.

  4. The next step is to configure the VSFTPD service

    Where guest_username means to specify the owner of the virtual user's default access. In cases where the path is not specifically specified, the default access is Ftpuser's home directory

  5. after the configuration, write some files to be used for testing

    #1, create the default first

    Plus permissions

    #2, create two virtual users, set different permissions, easy to test later

    Create a first virtual user profile:

    mkdir/etc/vsftpd/conf.d/

    Vim/etc/vsftpd/conf.d/ftp1

    Anon_upload_enable=yes

    cd/app/ftpdir/

    Touch F1

    mkdir up

    Chown Ftpuser up

    Create a second virtual user profile:

    Vim/etc/vsftpd/conf.d/ftp2

    Local_root=/app/ftp2

    Mkdir/app/ftp2

    Touch F2

Database side:

Install the database first, then set the database name, set up the table, configure the corresponding parameters in the table, and finally configure the database file in order to better connect with the server.

Steps:

    1. Installing the Database

      Yum Install Mariadb-server

      Open service

      Systemctl Start mariadb

    2. Run a security script to set a password for the connection database

    3. Create a database

Client:

Before testing, turn off all firewall policies and check if the service is open or not. All preparations are finished and the test begins.

Using the FTP service to connect to the FTP server side

Then enter the corresponding virtual user name and password to

Here you can see the file you just created under FTP1

You can also view the files under FTP2

The experiment is complete.

Implementing MySQL-based authentication for VSFTPD 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.