The server being used here is a Linux Cent OS Minimal installation build.
Cent OS 6
The virtual users home folders will be under /var/ftp/. You need to have either 'su' permissions or 'root' access or 'sudo' access.
As authentication will be required pam_userdb is a good option and is installed by default. Check with
#yum info db4-utils
Install it with
#yum install db4-utils as necessary
Create the virtual users:
Now cd to /etc/vsftpd and prepare the .txt user file with the usernames and passwords. This file will have a username in single line and the password in the next as shown. It is good practice to put these in a separate folder.
A pwd should show /etc/vsftpd/vuser, now create the file
Add your users and save it. This file now needs to be hashed with the DB4-util db_load so that vsftpd along with pam can use it for authentication.
#db_load -T -t hash -f /etc/vsftpd/vuser/vuser_list /etc/vsftpd/vuser/vuser_db.db
A hashed DB file of the vuser_list is created named vuser_db.db. Note that the file has a .db extension and this is necessary.
Enable Authentication with PAM:
Now append to the file /etc/pam.d/vsftpd for this virtual user authentication to work.
Put these two lines at the very top of the file just below the #%PAM-1.0 line and save it. PAM_Userdb will automatically append the extension .db to the file specified in the path. This way you can have both real shell users and virtual users using the same instance of the daemon rather than starting two process of vsftpd.
auth sufficient pam_userdb.so db=/etc/vsftpd/vuser/vuser_db
account sufficient pam_userdb.so db=/etc/vsftpd/vuser/vuser_db
Append Options to vsftpd.conf:
Do the following changes to the vsftpd config file at /etc/vsftpd/vsftpd.conf
Also disable SELinux in /etc/selinux/config so that the virtual user can write to the virtual directories under /var/ftp/vuser/$USER. Now change to the virtual user folder
- activate the virtual users
virtual users have local priveleges
# specifies a home directory for each virtual user
to the FTP area and HOME dir's only
Create the Virtual User Folders:
#chown -R ftp:ftp /etc/ftp/vuser/
Create system links with ln -s of all the /home/ folders under /var/ftp/vuser/ so that when the users login VSFTPD will chroot to their respective folders.
BASH Scripts and how to article for automation is at http://sudhakarbellamkonda.blogspot.com/2011/12/vsftpd-virtual-users-creation-bash.html
Scripts maintained at vsftpd-virtualuser-bash-scripts.
For Local Users:
In folder /var/ftp/vuser/
#chown ftp:ftp yourlocaluser
#ln -s /var/ftp/vuser/yourlocaluser /home/yourlocaluser/ftphome
All file uploaded will be owned by the user ftp:ftp.
Starting the server and testing:
Start the service
#service vsftpd start
Or restart it if already started with
#service vsftpd restart
From a different box connect to this server. Go on, you can use either a GUI or a cli client.
All set, go on use the FTP server, it is ready to serve.