SoFunction
Updated on 2025-04-14

Share the full tutorial on vsftp configuration under RHEL 5.2



2. Use MySQL data files:

Create a local mapped user.

useradd -s /sbin/nologin vuser

Modify /etc/vsfptd/ and add the following content.

guest_enable=YES
guest_username=vuser

Install MySQL and related software packages.

yum -y install *

yum -y install *

yum -y install *

yum -y install *

Create database and user tables in MySQL.

[root@polo ]# mysql -u root mysql -p
mysql>create database ftpvuser;                       #Create a user database
mysql>use ftpvuser;                                 #Open the database
mysql>create table users(name char(16) binary,passwd char(16) binary);  #Create a user information table
#Insert two users and passwords
mysql>insert into users (name,passwd) values ('tonyzhang',password('111'));
mysql>insert into users (name,passwd) values ('tomqin',password('111'));

Authorized vuser can read the users table of the ftpvuser database.


[root@polo ]# mysql -u root mysql -p

mysql>grant select on to vuser@localhost identified by '123';

mysql>quit

After the above authorization is completed, you can verify whether the authorization is successful through the following method.

 


Compile MySQL's PAM authentication module.

First, you need to download (/projects/pam-mysql) MySQL's PAM authentication module source code, decompress it using the tar command and compile it. The following packages need to be installed before compiling.

yum -y install *

yum -y install gcc-c++.i*

yum -y install *

After the installation is completed, it can be compiled.

./configure
make
make install

After editing, you can check whether there is a corresponding pam module in the /lib/security directory (as shown below).

 

Modify the pam authentication file /etc//vsftpd and comment on the original content.

auth required pam_mysql.so user=vuser passwd=123 host=localhost db=ftpvuser table=users usercolumn=name passwdcolumn=passwd crypt=2
account required pam_mysql.so user= vuser passwd=123 host=localhost db= ftpvuser table=users usercolumn=name passwdcolumn=passwd crypt=2


After the above two virtual user configurations are completed, different configuration files can be specified for each virtual user through the following steps.

1. Modify /etc/vsfptd/

user_config_dir=/etc/vsftpd/vuserconf

2. In the /etc/vsfptd/ directory, create a configuration file with the user name of each virtual user.

5. Virtual host.

By default, vsftp does not create multiple ftp sites on the same host like IIS, but there is not a way to create multiple ftp sites on the same host. The method is as follows:

1. Add a virtual IP address (eth0's IP address 192.168.0.10)

ifconfig eth0:0 192.168.0.11/24
2. Create a virtual FTP service user


useradd -d /var/ftp2 -s /sbin/nologin ftp2       
chmod -R 755 /var/ftp2
chown -R root:root /var/ftp2
mkdir -m 755 /var/ftp2/pub
chown ftp2:root /var/ftp2/pub

3. Prepare the configuration file for the virtual FTP server

cp /etc/vsfptd/ /etc/vsfptd/

4. Modify /etc/vsftpd/

listen_address=192.168.0.10
5. Modify /etc/vsftpd/

listen_address=192.168.0.11
ftp_username=ftp2
local_root=/var/ftp2