Introduction

If you are looking to install an FTP server on Ubuntu, you can’t beat the simplicity of VSFTPD.

FTP stands for File Transfer Protocol. It is similar to HTTP (HyperText Transfer Protocol), in that it specifies a language for transferring data over a network. FTP is unencrypted by default, so by itself, it’s not a good choice for secure transmissions.

This guide will help you install and configure an FTP server (VSFTPD) on Ubuntu 18.04.

installation of an ftp server on Ubuntu with VSFTPD

Prerequisites

  • Access to a user account with sudo privileges
  • Access to a terminal window/command line (Ctrl-Alt-T)
  • The apt package manager, included by default

Step 1: Update the System Packages

Start by updating your repositories – enter the following in a terminal window:

sudo apt-get update

Step 2: Backup Configuration Files

Before making any changes, make sure to back up your configuration files.

1. Create a backup copy of the default configuration file by entering the following:

sudo cp /etc/vsftpd.conf  /etc/vsftpd.conf_default

This command creates a copy of the default configuration file.

2. Create a new VSFTPD configuration file /etc/vsftpd.conf using your preferred text editor:

$ sudo nano /etc/vsftpd.conf

Step 3: Install VSFTPD Server on Ubuntu

A common open-source FTP utility used in Ubuntu is vsftpd. It is recommended for its ease of use.

1. To install vsftpd, enter the command:

sudo apt install vsftpd

2. To launch the service and enable it at startup:

sudo systemctl start vsftpd

sudo systemctl enable vsftpd

Step 4: Create FTP User

Create a new FTP user with the following commands:

sudo useradd –m testuser

sudo password testuser

The system should ask you to create a password for the new testuser account. Create a sample file in the new user’s home account:

sudo mkdir /home/testuser

Step 5: Configure Firewall to Allow FTP Traffic

If you are using the UFW that comes standard with Ubuntu, it will block FTP traffic by default. Enter the following commands to open Ports 20 and 21 for FTP traffic:

sudo ufw allow 20/tcp

sudo ufw allow 21/tcp

Note: if you’re using a different firewall, refer to the instructions to allow access on Port 20 and Port 21. These are the listening ports for the FTP service.


Step 6: Connect to Ubuntu FTP Server

Connect to the FTP server with the following command:

sudo ftp ubuntu-ftp

Replace ubuntu-ftp with the name of your system (taken from the command prompt).

Log in using the testuser account and password you just set. You should now be successfully logged in to your FTP server.

Configuring and Securing Ubuntu VsFTPD Server

Change Default Directory

By default, the FTP server uses the /srv/ftp directory as the default directory. You can change this by creating a new directory and changing the FTP user home directory.

To change the FTP home directory, Enter the following:

sudo mkdir /srv/ftp/new_location

sudo usermod –d /srv/ftp/new_location ftp

Restart the vsftpd service to apply the changes:

sudo systemctl restart vsftpd.service

Now, you can put any files you want to share via FTP into the /srv/ftp folder (if you left it as the default), or the /srv/ftp/new_location/ directory (if you changed it).

Authenticate FTP Users

If you want to let authenticated users upload files, edit the vsftpd.conf file by entering the following:

sudo nano /etc/vsftpd.conf

Find the entry labeled write_enable=NO, and change the value to YES. Save the file, exit, then restart the FTP service with the following:

sudo systemctl restart vsftpd.service

This allows the user to make changes inside their home directory.

Securing FTP

Limit User Access

Numerous exploits take advantage of unsecured FTP servers. In response, there are several configuration options in vsftpd.conf that can help secure your FTP server.

One method is to limit users to their home directory. Open vsftpd.conf in an editor, and uncomment the following command:

chroot_local_user=YES

Create a User List File

To create a list file, edit /etc/vsftpd.chroot_list, and add one user per line.

Instruct your FTP server to limit this list of users to their own home directories by editing vsftpd.conf:

chroot_local_user=YES

chroot_list_file=/etc/vsftpd.chroot_list

Restart the vsftpd service:

sudo systemctl restart vsftpd.service

By default, the lost of blocked users from FTP access is stored in /etc/ftpusers. To add blocked users, edit this file and add one user per line.

Encrypt Traffic With FTPS

Another method to secure your FTP server is to encrypt the traffic. This is done by using FTPS – File Transfer Protocol over SSL (Secure Socket Layer).

Users need to be set up with a shell account on the FTP server, but this will add a layer of secure encryption to your FTP traffic. To set up FTPS, open your vsftpd.conf file in an editor, and add the following lines:

ssl_enable=YES

rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem

rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

Restart the service to apply the changes:

sudo systemctl restart vsftpd.service

Note: For more information on SSL configurations and certificates, please see the Ubuntu FTP server documentation. Also, it’s worth noting that FTPS is a different protocol that SFTP. SFTP stands for Secure File Transfer Protocol, and it’s an entirely different protocol.


Conclusion

Now, you should have installed an FTP server on Ubuntu with VSFTPD.

You should now be able to configure your user lists and accounts and connect to your new FTP server. We also detailed the risks of the FTP protocol, and how to mitigate them.