Setting up an FTP Server on Ubuntu

File Transfer Protocol (FTP) is a network protocol used for transferring computer files between a client and server on a computer network. FTP is built on a client-server model architecture and utilizes separate control and data connections between the client and the server. FTP servers are commonly used to share files with remote users, back up data, or transfer large files over a network. Ubuntu is a popular Linux distribution widely used for personal computers, servers, and cloud computing environments.

In this post, we will discuss how to set up an FTP server in the Ubuntu operating system. This can be accomplished using various FTP server software packages. Furthur will discuss setting up an FTP server in Ubuntu using the popular vsftpd (Very Secure FTP Daemon) 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 Install SSL on Linux VPS Using Certbot

Securing your website with SSL stands for Secure Socket...

Nohup Command in Linux

The Nohup command, which stands for "no hang up," is a ...

How to Check Disk Free Space on Linux

Checking and managing free space on your system disk is...

How to Check Kali Linux Version

Kali Linux is a Debian-based Linux distribution aimed a...

Exploring Linux cut Command with Examples

The Linux cut command is a powerful utility that allows...

How to Use the Linux Sleep Command

The sleep command in Linux is designed to introduce a d...

Leave a Comment