How to Install a FTP Server on Ubuntu VPS

Posted on October 7, 2024 | Updated on October 11, 2024

Installing an FTP (File Transfer Protocol) server on Ubuntu VPS (Virtual Private Server) is a great way to manage file transfers. It provides a simple and secure way to upload and manage files remotely, making it essential for developers.

To go through the process of installing an FTP server, you’ll first need to ensure you have the right setup.

Prerequisites for Installing an FTP Server on Ubuntu VPS

Before you get started with installing an FTP server on Ubuntu VPS, there are a few things to have in place:

  • An Ubuntu VPS: Make sure you have this set up and ready to go. These steps work for most versions of Ubuntu, but it’s always better to check if you’re using an up-to-date version to avoid compatibility issues.
  • Root or Sudo Access: You’ll need a root or a user account with sudo privileges. This allows you to run commands as an administrator and make necessary changes to your server.
  • A stable internet connection: Since you’ll be working on a remote server, ensure your internet connection is strong. Any interruptions can cause issues during the setup process.
  • Basic knowledge of terminal commands: This process requires a basic understanding of commands to make it much easier. However, this guide will walk you through each command step by step.

Step 1: Update and Upgrade System Packages

Updating your system packages is essential to avoid conflicts when installing your new software. It also ensures you’re working with the latest security patches and features. Use the following instructions to update them.

First, log in to your Ubuntu VPS using SSH. You can access your server using a terminal like PuTTY. Here’s a basic command example of what SSH would look like.

Command ssh username@hostname

Once logged in, refresh the package list to see if any updates are available. Use the command in the first line of the following image to fetch the latest list of packages and updates available from the Ubuntu repositories.

After updating the package list, you will use the second command to upgrade all the packages on your server to the latest version.

1 sudo apt update 2 sudo apt upgrade -y

The -y flag automatically confirms the installation of updates, so you avoid manually approving each one. 

Step 2: Install the FTP Server Software (vsftpd)

Now that your Ubuntu VPS is up to date, it’s time to install the FTP server software. For this step, you’ll be using vsftpd (Very Secure FTP Daemon), a fast and secure FTP server that’s widely used and easy to set up. 

Using vsftpd is a good choice for FTP servers on Linux because of its security and reliability. It supports various configurations, making it suitable for basic and advanced setups. So, the first step to installing vsftpd on your Ubuntu VPS is to run the following command.

sudo apt install vsftpd -y

This command uses the package manager to download and install vsftpd. To verify that you installed it correctly, you can use the following command to display the version currently installed on your system.

# Check if OpenSSH Server is installed
dpkg -l | grep openssh-server

# Check the status of the SSH service
systemctl status ssh

Once you’ve verified its installation, you must start its service and ensure it automatically starts on server reboot. Use the following commands.

1 sudo systemctl start vsftpd
2 sudo systemctl enable vsftpd

The start command initializes the vsftpd service, and the enable command ensures it runs automatically whenever VPS restarts.

Step 3: Configure the FTP Server

With vsftpd installed, now you can configure it according to your needs. The default settings are typically secure, but making a few adjustments can improve functionality and tailor the server to your preferences.

First, locate and open the configuration file, which is located in the /etc directory. To edit it, open the file using a text editor like Nano.

sudo nano /etc/vsftpd.conf

This command will open the vsftpd configuration file, where you can adjust various settings. For instance, if you want your server’s local users to access the FTP server, ensure that the line is enabled.

local_enable=YES

To allow users to upload files to the server, enable the write_enable option.

write_enable=YES

For security purposes, it’s highly essential to restrict anonymous access.

anonymous_enable=NO

After making your changes, save the file using CTRL + X, then Y to confirm, and Enter to exit. For the changes to take effect, restart the vsftpd service using the following command.

sudo systemctl restart vsftpd

Step 4: Set Up Firewall Rules

To ensure your FTP can communicate properly, you’ll have to configure the firewall to allow FTP traffic. By default, FTP uses port 21 for communication, so you’ll need to make sure this port is open on your Ubuntu VPS.

To do this, allow this port through the firewall using the following command.

sudo ufw allow 21/tcp

This command opens port 21 for TCP traffic, enabling your FTP server to communicate with clients.

If you configured your FTP server to use passive mode in the previous step, make sure to allow the range of ports defined in your vsftpd.conf. For example:

sudo ufw allow 10000:10100/tcp

Next, you’ll need to apply these changes to reload the firewall rule with this command.

sudo ufw reload

Step 5: Create an FTP User Account

Now, you’ll need to create a user account with permissions to connect and manage files. Set up a user and figure out their access by creating a new user — you can replace ftpuser with any username of your choice. 

sudo adduser ftpuser

It will then prompt you to set a password and provide optional information like your full name, phone number, and more. You can also press Enter to skip these fields if unnecessary.

By default, the user’s home directory is set to /home/ftpuser. You may want to restrict their access to only this directory or a specific folder. To do this, you need to change the directory’s ownership and permissions.

sudo chown ftpuser:ftpuser /home/ftpuser

This sets ftpuser as the owner of the directory, ensuring they have the appropriate permissions to manage files within it. 

Step 6: Test the FTP Server

With your FTP server and user account set up, you can start testing the connection to ensure everything works correctly. Consider testing every four to six months to guarantee a proper connection. 

First, download an FTP client to connect to your FTP server. Popular options include:

  • FileZilla
  • Cyberduck
  • WinSCP

Download and install one of these clients. Then, open it and create a new connection. You’ll need to provide the following information:

  • Host: The IP address of your Ubuntu VPS.
  • Port: The default FTP port is 21.
  • Protocol: Use FTP – File Transfer Protocol.
  • Logon Type: Choose Normal.
  • Username: The username you created earlier.
  • Password: The password associated with the FTP server.

If everything is correct, you should be able to connect to your FTP server and see the contents of the user’s home directory. To test this, try uploading a test file to the directory by dragging and dropping a file. Then, try downloading it back to your local machine. This confirms that both upload and download functionalities are working properly.

Installing an FTP Server on Ubuntu VPS

These steps show you how to install and configure an FTP server on Ubuntu VPS. While FTP is a great way to transfer files, always remember to secure your server and stay updated with best practices to keep your data safe. Whether managing a personal project or setting up file-sharing for a team, having a secure FTP server on Ubuntu will help you maintain control over your file transfers.

Related Posts

About The Author

Coraline (Cora) Steiner is the Senior Editor of Designerly Magazine, as well as a freelance developer. Coraline particularly enjoys discussing the tech side of design, including IoT and web hosting topics. In her free time, Coraline enjoys creating digital art and is an amateur photographer.

Leave a Comment