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

React implements the sample code of Radio component

This article aims to use the clearest structure t...

Code analysis of synchronous and asynchronous setState issues in React

React originated as an internal project at Facebo...

Free tool to verify that HTML, CSS and RSS feeds are correct

One trick for dealing with this type of error is t...

idea combines docker to realize image packaging and one-click deployment

1. Install Docker on the server yum install docke...

Summary of MySQL lock knowledge points

The concept of lock ①. Lock, in real life, is a t...

Detailed application of Vue dynamic form

Overview There are many form requirements in the ...

Unicode signature BOM detailed description

Unicode Signature BOM - What is the BOM? BOM is th...

How to start Vue project with M1 pro chip

Table of contents introduction Install Homebrew I...

js development plug-in to achieve tab effect

This article example shares the specific code of ...

Nginx Service Quick Start Tutorial

Table of contents 1. Introduction to Nginx 1. Wha...

Web Design: When the Title Cannot Be Displayed Completely

<br />I just saw the newly revamped ChinaUI....

Compile CPP files using G++ in Ubuntu

When I used g++ to compile the cpp file for the f...

MySQL calculates the number of days, months, and years between two dates

The MySQL built-in date function TIMESTAMPDIFF ca...