Configuring FTP server (vsftpd) using text file for virtual users

Sponsored Link
vsftpd is a GPL licensed FTP server for UNIX systems, including Linux. It is secure and extremely fast. It is stable. Don't take my word for it, though. Below, we will see evidence supporting all three assertions. We will also see a list of a few important sites which are happily using vsftpd. This demonstrates vsftpd is a mature and trusted solution.

VsFTPd Features

Despite being small for purposes of speed and security, many more complicated FTP setups are achievable with vsftpd! By no means an exclusive list, vsftpd will handle:

Virtual IP configurations
Virtual users
Standalone or inetd operation
Powerful per-user configurability
Bandwidth throttling
Per-source-IP configurability
Per-source-IP limits
Encryption support through SSL integration

Install VsFTPd server on ubuntu

Open the terminal and run the following command

sudo apt-get install vsftpd

Virtual users and authentication

We are going to use pam_userdb to authenticate the virtual users. This needs a username / password file in `db’ format – a common database format. We need `db_load’ program.

sudo apt-get install db5.3-util

To create a `db’ format file, first create a plain text file `virtual-users.txt’ with the usernames and passwords on alternating lines:


Then execute the following command to create the actual database:

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

Now, create a PAM file /etc/pam.d/vsftpd.virtual

sudo vi /etc/pam.d/vsftpd.virtual

Add the following lines

auth required db=/etc/vsftpd/virtual-users
account required db=/etc/vsftpd/virtual-users

Save and exit the file

Configuring Vsftpd Server

Edit vsftpd configuration file /etc/vsftpd.conf

sudo vi /etc/vsftpd/vsftpd.conf

Edit the following options

# disables anonymous FTP


# enables non-anonymous FTP


# activates virtual users


# virtual users to use local privs, not anon privs


# enables uploads and new directories


# the PAM file used by authentication of virtual uses


# in conjunction with ‘local_root',
# specifies a home directory for each virtual user


# the virtual user is restricted to the virtual FTP area


# hides the FTP server user IDs and just display "ftp" in directory listings


# runs vsftpd in standalone mode


# listens on this port for incoming FTP connections


# the minimum port to allocate for PASV style data connections


# the maximum port to allocate for PASV style data connections


# controls whether PORT style data connections use port 20 (ftp-data)


# the umask for file creation


Creation of home directories

Create each user’s home directory in /var/www/virtual, and change the owner of the directory to the user `ftp’:

sudo mkdir /var/www/virtual/andy
sudo chown ftp:ftp /var/www/virtual/andy

Restart VSFTPD service

Now we can restart VSFTPD using the following command

sudo service vsftpd restart

Test Your vsftpd Setup

Open the terminal and type the following

$ ftp localhost

Sample success output:

Connected to
Name (localhost:root): andy
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

Sponsored Link

Incoming search terms:

Related posts

Leave a comment

Your email address will not be published. Required fields are marked *