Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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'

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report