In this tutorial, let’s learn how to install FTP server on Ubuntu. FTP or File Transfer Protocol is a protocol used to transfer files between two remote servers over the network.
Just like HTTP is used to transfer data over the network through web browsers, FTP is commonly found being used by command-line users.
When you wish to install FTP server on Ubuntu, you have got a variety of open source FTP servers to choose from. However, for this tutorial, we will install the vsftpd (Very Secure FTP Daemon) server on our system.
Table of Contents
- 1 What’s needed to Install FTP Server on Ubuntu?
- 2 Steps to Install FTP Server on Ubuntu
- 3 Configuring your FTP server on Ubuntu
- 4 Conclusion
What’s needed to Install FTP Server on Ubuntu?
This tutorial was made with an Ubuntu 18.04 running system. However, the same instructions will work on Ubuntu 16.04 and Debian based distributions like Elementary OS, Linux Mint and Debian.
You would also need a non-root user with sudo privileges to follow this tutorial where we install FTP server on Ubuntu.
Steps to Install FTP Server on Ubuntu
To install FTP server on Ubuntu, you don’t need to download anything. This is because the FTP server package comes with the default Ubuntu repository. The package that we’ll use is named vsftpd and can be accessed using the apt command.
1. Update and Upgrade Repositories
Before we begin to install FTP server on Ubuntu, we need to update our default repositories using the apt package management service.
To do this, you need to open the terminal on your Ubuntu system and type the following.
sudo apt update && sudo apt upgrade
These commands update the Ubuntu repositories with the latest available repositories for your system.
Now, this ensures that we will get the latest version of the vsftpd package when we install the FTP server on our system.
2. Installing the vsftpd package
Now that we understand what an FTP server does, and have covered the prerequisites, it is time to install FTP server on our system. To do so, you need to follow the following steps.
Now that we have the desired repository, we can proceed with the tutorial. We will use the apt package management service to install FTP server on Ubuntu.
To do so, we enter the following in our terminal. You might be prompted to enter your user password to continue.
sudo apt install vsftpd
When you enter this command in your command line, this is what you should expect to see as the output on your screen.
This command will tell the apt package manager to fetch the vsftpd package from our system repository.
3. Verifying our installation
Once we install FTP server on Ubuntu, We can verify this by asking the terminal for the status of our vsftpd service. To do so, we enter this in our terminal.
sudo systemctl status vsftpd
This will fetch the details of the current status of the FTP server on our system. If we made no mistakes, the current status of our vsftpd service should be ‘running’ as seen in the screenshot above.
Configuring your FTP server on Ubuntu
When you install FTP server on Ubuntu, you need to configure it before it can be used.
1. Create a Backup of the Default Configuration
Before we make any custom configurations, it is a recommended practice to create a copy of the default vsftpd configuration file as a backup in case we want to reset our configuration.
This can be done using the cp command as shown below.
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf_backup
2. Add Custom Configuration
Now that we have a backup, we can start customizing the vsftpd configuration file. Let’s open the configuration file using the nano editor. You need to use this command to do so.
sudo nano /etc/vsftpd.conf
Now we edit the configuration file to make necessary changes. The below table contains all the edits we make in this tutorial and what they do.
|These block access for anonymous users, while enabling local users to access the FTP server.|
|write_enable=YES||This allows changes to the filesystem when you upload or delete something through the FTP server.|
|chroot_local_user=YES||This prevents a user from accessing files beyond their home directory.|
|When chroot is enabled, vsftpd doesn’t allow uploads to prevent security risks. This creates an ftp directory in the user home to serve as the chroot. Later, we can create a new writable directory for the uploads.|
|This assigns the ports between the range 30000 and 31000 for passive FTP connections.|
You can also specify certain users that can login while denying anyone who’s not on the list by creating a file “/etc/vsftpd.allowed_users” and adding the usernames here.
Once you have that set up, you can add the following lines to the configuration file:
3. Open Ports for Incoming FTP Requests
Now, we have been successful to install FTP server on Ubuntu and set some configurations.
It’s time to update the firewall settings using the ufw command so that our FTP server can listen through port numbers 20 and 21.
We will also open the port range 30000 to 31000, which we assigned for passive FTP connections. Enter these commands in your terminal.
sudo ufw allow 30000:31000/tcp sudo ufw allow 20/tcp sudo ufw allow 21/tcp
Now port 20 and 21 will work as listening ports for our FTP server. We will now check the status of ufw using the following command so that its rules are updated.
sudo ufw status
4. Restart FTP Server
Finally, we will use systemctl to restart the vsftpd service.
sudo systemctl restart vsftpd
Now we are done with our quest to install FTP server on Ubuntu. Go ahead and connect to your FTP server
While newer and faster protocols exist now, FTP remains relevant for legacy support and workplaces with highly specific requirements.
It’s an important thing to keep in mind that FTP is an unencrypted network protocol by default.
Hence, it is not a recommended protocol to be used for securely transferring data without sufficient safety mechanisms in place.
This tutorial aimed to help you install FTP server on Ubuntu and set some basic configuration in place.