1. Installation of vsftpd

For CentOSRHEL and Fedora, you can install vsftpd with yum:

# yum install vsftpd

2. Virtual users and authentication 

In Linux, we are going to set up virtual users using pam_userdb. This needs a username / password file in “db” format. We need db_load program.

# yum install db4-utils

To create a ‘db’ format file, first create a plain text file “virtual-users.txt” with the user names and passwords on alternating lines:

adrian
password123
john
123pass

Then execute the following command to create the actual database:

# db_load -T -t hash -f virtual-users.txt /etc/vsftpd/virtual-users.db

For security reasons you should remove the plain text file:

Now, create a PAM file /etc/pam.d/vsftpd-virtual which uses your database:

auth required pam_userdb.so db=/etc/vsftpd/virtual-users
account required pam_userdb.so db=/etc/vsftpd/virtual-users
session required pam_loginuid.so

3. Configuration of vsftpd

Edit the vsftpd configuration file /etc/vsftpd/vsftpd.conf (or /usr/local/etc/vsftpd.conf for FreeBSD). Add or correct the following configuration options:

# enable background mode
background=YES
# disables anonymous FTP
anonymous_enable=NO
# enables non-anonymous FTP
local_enable=YES
# activates virtual users
guest_enable=YES
# virtual users to use local privs, not anon privs
virtual_use_local_privs=YES
# enables uploads and new directories
write_enable=YES
# the PAM file used by authentication of virtual uses
pam_service_name=vsftpd-virtual
# in conjunction with ‘local_root’,
# specifies a home directory for each virtual user
user_sub_token=$USER
local_root=/var/www/virtual/$USER
anon_root=/var/www/ftp
# the virtual user is restricted to the virtual FTP area
chroot_local_user=YES
# hides the FTP server user IDs and just display “ftp” in directory listings
hide_ids=YES
# runs vsftpd in standalone mode
listen=YES
# listens on this port for incoming FTP connections
listen_port=21
# the minimum port to allocate for PASV style data connections
pasv_min_port=65500
# the maximum port to allocate for PASV style data connections
pasv_max_port=65535
# controls whether PORT style data connections use port 20 (ftp-data)
connect_from_port_20=YES
# the umask for file creation
local_umask=022
# Restrict connections
max_clients=20
max_per_ip=10
# secured empty directory
secure_chroot_dir=/usr/share/empty

Create /usr/share/empty and /var/www/ftp :

# mkdir -p /usr/share/empty
# mkdir -p /var/www/virtual

4. Creating home directories

Create home directories in /var/www/virtual, and change the owner of the directory to the user “ftp” :

# mkdir /var/www/virtual/users
# chown -R ftp:ftp /var/www/virtual

Change the home directory of the ftp user to /var/www/virtual (or /var/www):

Linux
# usermod -d /var/www/virtual ftp

5. Starting vsftpd and testing vsftpd configuration

Startsftpd using the following command:

# service vsftpd start

from: http://blog.up-link.ro/how-to-set-up-vsftpd-virtual-users-berkeley-db-pam/