How to Build an Efficient FTP Virtual User System on Linux

    VSFTP is an FTP server software for Unix-like systems released under the GPL. Its full name is Very Secure FTP, and as the name suggests, the developer’s primary focus was code security.

The following procedure is demonstrated on CentOS 5.

Install vsftp

yum install vsftpd

Create Log File

touch /data1/logs/vsftpd.log

Modify vsftp Configuration File

vi /etc/vsftpd/vsftpd.conf

Parameter Settings. Note: Type “/search term” to quickly find entries. Be careful not to introduce any extra spaces.

anonymous_enable=NO #Disable anonymous access

local_enable=YES #Allow local users to access

chroot_list_enable=YES #Restrict users to their home directories

xferlog_file=/var/log/vsftpd.log #Path for the vsftpd service log file; does not exist by default

ascii_upload_enable=YES #Allow uploads

ascii_download_enable=YES #Enable ASCII mode download support

pam_service_name=vsftpd #Do not forget to add this

Manually enter the following parameters and values

guest_enable=YES #Enable virtual user functionality

guest_username=ftp #The system user that virtual users map to

user_config_dir=/etc/vsftpd/vuser_user

Create chroot list

touch /etc/vsftpd/list

echo ftp>>/etc/vsftpd/list

Perform authentication. If db_load is not found, install db4-utils first (yum install db4 db4-utils)

vi /etc/vsftpd/vsftp_users.conf

Enter odd lines as usernames and even lines as passwords

www_lingdus_com #Username

www_lingdus_com #Password

Generate Authentication File

db_load -T -t hash -f /etc/vsftpd/vsftp_users.conf /etc/vsftpd/vsftp_users.db

Edit the PAM authentication file. Clear or comment out all existing content.

vi /etc/pam.d/vsftpd

After clearing the file, enter:

auth required pam_userdb.so db=/etc/vsftpd/vsftp_users

account required pam_userdb.so db=/etc/vsftpd/vsftp_users

Customize User Settings

mkdir /etc/vsftpd/users/

vi /etc/vsftpd/vuser_conf/www_lingdus_com

Add the following content

local_root=/data0/htdocs/lingdus/bbs #Its root directory

write_enable=YES

anon_umask=022

anon_world_readable_only=NO

anon_upload_enable=YES

anon_mkdir_write_enable=YES

anon_other_write_enable=YES

Done. Start or restart vsftp

service vsftpd restart

You can now connect to FTP

IP: XXX.XXX.XXX.XXX

Port: 21

Username: www_lingdus_com

Password: www_lingdus_com

If you encounter the error “553 Could not create file” or cannot upload when connecting to FTP, disable SELinux

Terminal: setsebool -P ftpd_disable_trans 1

Restart: service vsftpd restart

Alternatively, change

guest_username=ftp #The system user that virtual users map to

to

guest_username=root #The system user that virtual users map to

Restart: service vsftpd restart

If you encounter the error “500 OOPS: bad bool value in config file for: XXX” when starting or connecting to FTP

It is very likely that there are extra spaces in your parameter settings, or a parameter name is incorrect. Double-check carefully.

This tutorial is from the Lingdu Technology Forum. Original link: http://www.lingdus.com/thread-4809-1-1.html

Because the IE browser upgrade disabled the Alt+X shortcut, please use the Alt+Q shortcut to quickly access the post entry

Leave a Comment

Your email address will not be published.