vsftpd virtual user based on MySql authentication

vsftpd virtual user based on MySql authentication

1. MySQL installation

yum -y install mariadb-server
systemctl enable --now mariadb.service

1.2 Create tables, databases, and users

mysql -e "CREATE DATABASE vsftpd;USE vsftpd;
CREATE TABLE users (id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
name CHAR(50) BINARY NOT NULL,
password CHAR(48) BINARY NOT NULL);
INSERT INTO users(name,password) values('qiu',password('123456'));
INSERT INTO users(name,password) values('zhang',password('654321'));"
mysql -e "select * from vsftpd.users;"

insert image description here

1.3 Create a remote connection account

mysql -e "create user vsftpd@'192.168.31.%' identified by 'Pana#123';"
mysql -e "grant all on vsftpd.* to vsftpd@'192.168.31.%';"

2. Install FTP server

2.1 Install vsftpd

yum install -y vsftpd

2.2 Install pam_mysql

yum -y install vsftpd gcc gcc-c++ make mariadb-devel pam-devel
wget http://prdownloads.sourceforge.net/pam-mysql/pam_mysql-0.7RC1.tar.gz
tar xf pam_mysql-0.7RC1.tar.gz
cd pam_mysql-0.7RC1/
./configure --with-pam-mods-dir=/lib64/security 
make install

2.2 Create the files required for PAM authentication

cat > /etc/pam.d/vsftpd.mysql<<EOF
auth required pam_mysql.so user=vsftpd passwd=Pana#123 host=mysqlserver db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2
account required pam_mysql.so user=vsftpd passwd=Pana#123 host=mysqlserver db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2
EOF

Note: The above refers to the README document
Crypt encryption method:
0 means no encryption
1 means crypt(3) encryption
2 means using mysql password() function to encrypt
3 means md5 encryption
4 means sha1 encryption

2.3 Create vsftpd user

mkdir -pv /data/ftproot/upload
useradd -d /data/ftproot -s /sbin/nologin -r vuser
setfacl -mu:vuser:rwx /data/ftproot/upload

2.4 Modify the vsftpd configuration file

mkdir /etc/vsftpd/conf.d/
sed -Eri "s#(pam_service_name=vsftpd)#\1.mysql#" /etc/vsftpd/vsftpd.conf
echo "guest_enable=YES" >> /etc/vsftpd/vsftpd.conf
echo "guest_username=vuser" >> /etc/vsftpd/vsftpd.conf

2.5 Restart vsftpd service

systemctl enable --now vsftpd

This is the end of this article about vsftpd virtual users based on MySql authentication. For more related MySql vsftpd virtual users content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • PureFTPd+Mysql+PHP_Manager to implement virtual user disk quota configuration method

<<:  The effect of zooming in on a Taobao store is similar to the principle of using a slideshow.

>>:  HTML Basics Must-Read---Detailed Explanation of Forms, Image Hotspots, Web Page Division and Splicing

Recommend

Share 10 of the latest web front-end frameworks (translation)

In the world of web development, frameworks are ve...

Several specific methods of Mysql space cleaning

Table of contents Preface 1. Check the file disk ...

The process of building and configuring the Git environment in Docker

Configure Git environment in Docker At work, I en...

mysql5.7.19 winx64 decompressed version installation and configuration tutorial

Recorded the installation tutorial of mysql 5.7.1...

Summary of Nginx load balancing methods

To understand load balancing, you must first unde...

Use the njs module to introduce js scripts in nginx configuration

Table of contents Preface 1. Install NJS module M...

Introduction to the use of several special attribute tags in HTML

The following attributes are not very compatible w...

How to deploy kafka in docker

Table of contents 1. Build Docker 2. Enter the co...

Examples of using the ES6 spread operator

Table of contents What are spread and rest operat...

Detailed tutorial on installing mysql8.0.22 on Alibaba Cloud centos7

1. Download the MySQL installation package First ...

Solution for multiple Docker containers not having the same port number

Background In Docker, four containers are created...

Vue implements multi-grid input box on mobile terminal

Recently, the company has put forward a requireme...

Is a design that complies with design specifications a good design?

In the past few years of my career, I have writte...

Vue achieves seamless carousel effect (marquee)

This article example shares the specific code of ...