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 :
- Installing the FTP Connection tool
Yum Install vsftpd
- 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
- 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.
- 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
- 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:
- Installing the Database
Yum Install Mariadb-server
Open service
Systemctl Start mariadb
- Run a security script to set a password for the connection database
- 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