This guide is about installing and configuring the well-known and secure VsFTPD (Very Secure File Transfer Protocol Daemon) server on your Ubuntu system. FTP or File Transfer Protocol is today a common network protocol that is used to transfer files between two computers or to transfer files from your desktop to your website or web hosting server. These files can be uploaded and downloaded depending on the user’s rights on the FTP server.
Let’s provide a step-by-step guide to install and then set up an FTP server on Ubuntu 18.04 LTS system. This is the easiest way to use FTP, and once you become familiar with it, you can move on to more advanced operations. Since we are using the Ubuntu command line in our tutorial, you can open it either with the system Dash or with the keyboard shortcut Ctrl + alt + T.
Installing an FTP Server
In this process, we will be installing the VsFTPD-Very secure FTP Daemon on our Ubuntu system. VsFTPD is more powerful and secure than native FTP.
Step 1: Install VsFTPD
To install the VsFTPD package through our Terminal, let’s first update our repositories with the following command:
$ sudo apt-get update
It’s time to install the latest available binary package for VsFTPD using the following command as root:
$ sudo apt-get install vsftpd
The system will ask you for credentials and may also give you the Y / n option to continue with the installation process. Please enter Y to continue.
After the installation is complete, you can verify this by checking the version number of the installed VsFTPD package as follows:
$ vsftpd -verions
The above output shows the version number and confirms that VsFTPD is now installed on your system.
Step 2. Start the VsFTPD service
When installing VsFTPD, the service is disabled by default. Let’s start the service with the following command:
$ systemctl start vsftpd
You will be prompted to provide user authentication as above. Enter your password and click the “Authentication” button. After that, the service will be started.
You can also enable the service to start automatically at boot using the following command:
$ systemctl enable vsftpd
You will be prompted to authenticate the user multiple times for different purposes. Enter your password and click the “Authentication” button.
Once the installation is complete, let’s set up and configure FTP on our Ubuntu system.
Step 1. Open ports 20 and 21 if firewall is enabled.
You can check the status of your firewall with the following command:
$ sudo ufw status
If the firewall is enabled and the status is active, you can open ports 20 and 21 with the following command:
$ sudo ufw allow 20/tcp $ sudo ufw allow 21/tcp
Again, if you look at the status of the firewall, you will see that these two ports are open and allowed:
Step 2. Configure vsftpd.conf and enable SSL / TLS.
The most important step in configuring FTP is to make some changes to the vsftpd config file. But before making any changes to this important file, let’s back it up with the following command:
$ sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig
Now open the config file in your favorite text editor. We use the nano editor to edit this file:
$ sudo nano /etc/vsftpd.conf
To do basic FTP configuration, copy the following settings to the end of the file:
listen=NO listen_ipv6=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES use_localtime=YES xferlog_enable=YES connect_from_port_20=YES chroot_local_user=YES secure_chroot_dir=/var/run/vsftpd/empty pam_service_name=vsftpd rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key ssl_enable=Yes pasv_enable=Yes pasv_min_port=10000 pasv_max_port=10100 allow_writeable_chroot=YES ssl_tlsv1=YES ssl_sslv2=NO ssl_sslv3=NO
Exit and save the file by pressing Ctrl + X and then hitting Enter.
Step 3. Restart the VsFTPD service.
After making changes to the vsftpd.conf file, you must restart the VsFTPD service for these changes to take effect. Enter the following command as root to restart the service:
$ sudo systemctl restart vsftpd
Step 4. Create FTP user
Let’s now create an FTP user who can use the FTP server using this command:
$ sudo useradd -m “username”
Assign a password to this user with this command:
$ sudo passwd “username”
In this example, we have created a user named sampleuser and assigned a password to it:
Let us also create sample file in the home directory of the new user. This file will later be used when testing our FTP connection:
$ sudo bash -c “echo This is a sample FTP file> / home / sampleuser / sampleFile”
Test the FTP connection
Finally, let’s test our FTP connection. I am testing this connection on localhost. You can use an available FTP server to test your connection:
$ ftp “hostname”
Here you need to provide the username and password of the user you created in order to access the FTP server.
After a successful login, you can view the list of available files using the ls command. In the following image, you can see the sample file we created in the sample user’s home directory.
You can also access the FTP server through a web browser by going to the FTP site. For example, to access the localhost, I will use the following link:
You can also easily access the available files from here.
So, we have presented the simplest and most basic procedure for installing and configuring an FTP server on your Ubuntu system. After following the above steps, you can access the FTP server and upload / download files from there.
How to Install VsFTPD Server with TLS in Ubuntu 18.04 LTS