Get the App
SLTechnology News&Howtos  ›  Database  › 

Integrate vsftp+pam+mysql- to centrally manage the virtual account of ftp

Shulou Source: shulou.com Published: 2022-06-01 13:58:00 10月01日 Update

Integrate vsftp+pam+mysql- to centrally manage the virtual account of ftp

First of all, a brief introduction to the basic principles:

There are three types of vsftp users, which are anonymous users, system users and virtual users.

In a sense, anonymous users are also system users, only a mapping of system users. The public ftp (such as virtual host) will not use the system user as the ftp account, but more virtual users, which can ensure the security of the system.

To use a virtual account, you need a container to store the virtual account, which can be a text list or an active directory, and more often use a database to store it.

In vsftp, both system users and virtual users use pam as a means of user authentication, but the mysql module is not supported by default in pam, so it is necessary to compile and install mysql module manually.

The overall idea is as follows:

Using pam as the middle layer of user authentication, the virtual user data in mysql is called and verified. The virtual user authentication is opened in vsftp, and the authentication method calls the mysql authentication and authorization module in pam to store the virtual user in mysql.

Step1:

Install vsftp and mysql first

[root@localhost ~] # yum install vsftpd mysql-server mysql-devel pam-devel-y

There is no mysql authentication module by default in PAM, so download the source code and install it manually.

[root@localhost] # tar-xf pam_mysql-0.7RC1.tar.gz-C / usr/src/

[root@localhost ~] # cd / usr/src/pam_mysql-0.7RC1

[root@localhost pam_mysql-0.7RC1] #. / configure-with-mysql=/usr/bin/mysql_config

[root@localhost pam_mysql-0.7RC1] # make & & make install

Step2:

Start mysql after installation

[root@localhost ~] # service mysqld start

[root@localhost] # mysql-uroot-p

First create the database of vsftp

Mysql > CREATE DATABASE vsftpd

Then create a user table

Mysql > use vsftpd

Mysql > create table users (

-> id int AUTO_INCREMENT NOT NULL

-> name char (20) NOT NULL UNIQUE KEY

-> passwd char (48) NOT NULL

-> primary key (id)

->)

Add the database account of vsftpd

Mysql > insert into users (name,passwd) values ('lustlost',password (' 123456'));\

Then create a database account for vsftpd. For security, only query permissions are granted.

Mysql > GRANT select on vsftpd.* to vsftpd@localhost identified by '123456'

Mysql > GRANT select on vsftpd.* to vsftpd@127.0.0.1 identified by '123456'

Tags: Users systems accounts data authentication databases modules security manual more authentication integration management middle tier hosts principles security containers ideas meaning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei macOS MariaDB NVidia