SoFunction
Updated on 2025-03-09

vsftpd virtual user configuration steps

yum -y install vsftpd*
yum -y install db4*
============================================================================
First create a text file containing the virtual user name and its password, and then generate the virtual user password library file on this basis:
#vim

Add the following information (single behavior username, even behavior password):
123     // Username
456     // Password

:wq        // Save and exit
==================================================================================
db_load -T -t hash -f /etc/vsftpd_login.db
chmod 600 /etc/vsftpd_login.db

=============================================================================
vi /etc//

auth required /lib/security/pam_userdb.so db=/etc/vsftpd_login
account required /lib/security/pam_userdb.so db=/etc/vsftpd_login

==============================================================================

Create a virtual user access directory and set permissions for virtual user access
#useradd -d /var/ftp/share -s /sbin/nologin virtual
#chmod 700 /var/ftp/share
=====================================================================================================
vim /etc/vsftpd/ adds below


chroot_local_user=YES
guest_enable=YES
guest_username=virtual
pam_service_name=
user_config_dir=/etc/vsftpd_user_conf

==================================================================================================
Create the user_config_dir file directory and create a configuration file named after the user name
#mkdir /etc/vsftpd/user_config_dir
#vi /etc/vsftpd/user_config_dir/1
anon_world_readable_only=NO
anon_upload_enable=YES                                   #?
write_enable=YES

download_enable=YES
anon_other_write_enable=YES
anon_mkdir_write_enable=YES
local_root=/var/ftp/share/123                                                                                                                      �

Other account configurations are based on the above parameters and set as needed..

===============================================================
vim /etc/vsftpd_user_conf/123


anon_world_readable_only=NO
anon_upload_enable=YES
write_enable=YES
download_enable=YES
anon_other_write_enable=YES
anon_mkdir_write_enable=YES
local_root=/var/ftp/share/123


mkdir -p /var/ftp/share/123
================================================
Whenever the step in creating a virtual user

1 Modify vim    Add user and password

 

2. Generate database
db_load -T -t hash -f /etc/vsftpd_login.db
chmod 600 /etc/vsftpd_login.db

 


3 Set different permissions for each virtual username
cp -p /etc/vsftpd_user_conf/123 /etc/vsftpd_user_conf/789
4 Set the permissions of vim /etc/vsftpd_user_conf/789 user


anon_world_readable_only=NO
anon_upload_enable=YES
write_enable=YES
download_enable=YES
anon_other_write_enable=YES
anon_mkdir_write_enable=YES
local_root=/var/ftp/share/789

=======================================================

mkdir -p /var/ftp/share/789

chown -R /var/ftp/share