Setting up an FTP Server on Ubuntu

File Transfer Protocol (FTP) refers to a network standard that allows the transmission computer files from a computer client to a server over a network, or vice versa. Its structure is built on the client-server framework and it uses separate control and data channels for communication between the client and the server. For distributing files to remote users, backing up files, or sending large files over a network, FTP servers are most commonly used. Ubuntu is a popular distribution of Linux that is used both by desktop and laptop users and on servers and cloud systems.

The goal of this post is to detail installing an FTP server on Ubuntu OS. There are many software packages that can be used but in the following section I will describe installing FTP server on Ubuntu using the popular vsftp server software.

Installation of FTP server in Ubuntu

Before proceeding with the installation, ensure that your Ubuntu system is up to date and has all the necessary packages installed. Run the following commands to update and upgrade your system:

sudo apt update && sudo apt upgrade -Y

Installing vsftpd

vsftpd, (or very secure FTP daemon) is an FTP server for Unix systems, which include Linux distribution. It is the default FTP package server in Ubuntu, CentOS, and Red Hat Enterprise Linux. Install vsftpd using the following command:

sudo apt install vsftpd

Configuring vsftpd

The main configuration file for vsftpd is located at /etc/vsftpd.conf. Open the file using a text editor like nano or vi:

sudo nano /etc/vsftpd.conf

Before changing anything in the configuration file, let’s discuss some of the important configuration options:

  1. anonymous_enable: This option enables or disables anonymous FTP access. To enable anonymous FTP, set this option to YES.
  2. local_enable: This option enables or disables local FTP access. To enable local FTP, set this option to YES.
  3. write_enable: This option enables or disables write access for FTP users. To enable write access, set this option to YES.
  4. anon_root: This option specifies the home directory for anonymous FTP users. The default value is /var/ftp
  5. local_root: This option specifies the home directory for local FTP users. The default value is /home.

Now you understand the options. Make the following changes to the configuration file:

anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
allow_anon_rwx=NO

These changes disable anonymous FTP access, enable local user access, allow writing to the FTP server, force local users to chroot to their home directories, and disallow anonymous users to read, write, or execute files.

Connection of FTP server in Ubuntu

After installing the FTP Server in Ubuntu we have to create a user before accessing the FTP server. The simplest way to do this is to use the adduser command. For example, to create an FTP user named ftpuser, run the following command in your terminal:

sudo useradd -r -s /bin/false -d /home/ftpuser ftpuser

This command creates a user named ftpuser with a home directory of /home/ftpuser and sets the user’s shell to /bin/false, preventing direct login to the FTP server using the ftpuser account.

Setting User Permissions

Set the appropriate permissions for the FTP user’s home directory:

sudo chown -R ftpuser:ftpuser /home/ftpuser

This command changes the ownership of the /home/ftpuser directory and its contents to the ftpuser user and group.

Allowing FTP Traffic Through the Firewall

If you are using a firewall, you must allow FTP traffic to pass through. In Ubuntu, you can use the UFW firewall management tool. Run the following commands to allow FTP traffic:

sudo ufw allow 21/tcp
sudo ufw allow 20/tcp
sudo ufw enable

These commands allow FTP traffic on ports 21 (for data connections) and 20 (for control connections) and enable the UFW firewall.

Restarting vsftpd

After making changes to the configuration file, you need to restart vsftpd for the changes to take effect. Run the following command in your terminal:

sudo systemctl restart vsftpd

Testing FTP connection

You can test your FTP connection using an FTP client such as FileZilla. To connect to your FTP server by configuring FileZilla, follow these steps:

  1. Open FileZilla.
  2. Enter the IP address of your FTP server in the host field.
  3. Enter the username ftpuser in the username field.
  4. Enter the password you set for the ftpuser account in the password field.
  5. Click the Quickconnect button.

If the connection is successful, you will see a list of files and directories on your FTP server in the File Listing panel.

Conclusion

In conclusion, installing an FTP server in Ubuntu is a straightforward process that can be completed in a few steps. By following the instructions provided in this article, you can easily set up an FTP server that you can use to transfer files between computers. However, it is important to note that FTP is an unencrypted protocol, which means that data transferred using FTP can be intercepted and read by third parties.

Establishing an FTP server on Ubuntu empowers you to seamlessly exchange files between your local device and the remote server. Ultahost comes with reliable and affordable VPS hosting plans. We offer a wide variety of plans to suit your needs, all at quality prices which include VPS full root access with SSD NVMe drive supported.

Related Post

How to Set Docker Environment Variables

Docker has revolutionized how we build, deploy, and run...

How to Use the Linux Head Command

File handling is a day-to-day task of Linux users and a...

Exploring the Linux tr Command

tr is a text manipulation command in Linux/Unix that is...

How to Fix Update and Upgrade Issues in Kali ...

Kali Linux is a powerful and versatile operating system...

How to Install Python on Ubuntu

As a favorite among novice and intermediate developers,...

Creating and Managing Files in Linux

Composed of multiple Operating Systems built on the Lin...

Leave a Comment