centos vsftpd virtual user installation configuration

install vsftpd
yum install -y vsftpd

yum install -y db4 db4-utils


Modify the FTP port firewall

vi /etc/vsftpd/vsftpd.conf
pasv_enable=YES --Enable passive mode
pasv_min_port=30000 -- minimum port in passive mode
pasv_max_port=31000 -- passive mode maximum port



Modify the firewall
--Open ports 20 and 21
iptables -I INPUT -p tcp -m multiport --dport 20,21  -m state --state NEW -j ACCEPT  


--open passive port          
iptables -I INPUT -p tcp --dport 30000:31000 -j ACCEPT   

service iptables save


configure boot

chkconfig --list|grep ftp   
 vsftpd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
 
chkconfig vsftpd on

start the service
service vsftpd start


Configure virtual users
touch /etc/vsftpd/virtual_user.txt
vi /etc/vsftpd/virtual_user.txt
root
root
db_load -T -t hash -f /etc/vsftpd/virtual_user.txt /etc/vsftpd/virtual_user.db



#Edit the authentication file, add the following two sentences after onrr=succeed
vi /etc/pam.d/vsftpd
auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed

auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtual_user
account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtual_user


#Create a virtual user configuration file

mkdir vconf
mkdir /etc/vsftpd/vconf/ #The
file name is equal to the account name in vuser_passwd.txt, otherwise the following settings are invalid
vi /etc/vsftpd/vconf/test
local_root=/var/ftp/pub/upload
anonymous_enable=NO
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES


Modify the configuration file
vi /etc/vsftpd/vsftpd.conf
#PAM authentication filename. PAM will authenticate against /etc/pam.d/vsftpd
pam_service_name=vsftpd
user_config_dir=/etc/vsftpd/vconf
#Set local users can access. Note: If you use virtual host users, all virtual users will not be able to access when this item is set to NO
local_enable=YES
#Make users can't leave home directory
chroot_local_user=YES


Restart the service
service vsftpd restart



Prompt: To allow anonymous users to support delete and rename permissions, the following parameters
anon_other_write_enable=YES must be added to vsftpd.conf to allow anonymous accounts to have delete. rename permissions

Add other directories to the ftp directory

mkdir newdir
mount --bind /usr/share/mydir/ /var/ftp/newdir/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326421221&siteId=291194637