How to Setup FTP Server with VSFTPD on Ubuntu 24.04?


FTP stands for File Transfer Protocol and it’s a way to move files between computers on the internet. VSFTPD is a type of FTP that’s known for being very secure and stable, especially in Linux systems. It’s a famous choice for setting up an FTP server, especially on Ubuntu systems.

Setting up an FTP server with VSFTPD on Ubuntu 24.04 serves the purpose of establishing a secure and efficient method for transferring files between different hosts over a network. It allows users to share files between devices with the option to restrict access to certain directories and to encrypt data transfers using SSL/TLS for enhanced security.

This article will give step-by-step instructions for setting up an FTP Server with VSFTPD on Ubuntu 24.04.

How to Setup FTP Server with VSFTPD on Ubuntu 24.04?

Setting up an FTP server on Ubuntu 24.04 involves a series of steps to ensure an efficient and secure file transfer process. To set up the FTP Server with VSFTPD on Ubuntu 24.04, follow the below steps:

Step 1: Install VSFTPD

FTP is a standard for sending files between our computers on a network. To install the VSFTPD server on Ubuntu 24.04, follow the below steps:

1. Update Package List

The process begins with updating the system packages using the “update” utility as below:

sudo apt update

2. Install VSFTPD

Now, install VSFTPD with the “vsftpd” package, which is available in the default Ubuntu repository:

sudo apt install vsftpd

3. Check VSFTPD Service

After the installation, it’s crucial to check that the VSFTPD service is active and running without errors using the “status” utility with the “systemctl” command:

systemctl status vsftpd

4. Enable and Start VSFTPD Service

Users can also enable as well start the VSFTPD service with the “systemctl” command by mentioning service names:

sudo systemctl enable vsftpd
sudo systemctl start vsftpd

That is all from the installation of VSFTPD on Ubuntu 24.04.

Step 2: Allow FTP Traffic From the Firewall

Configuring a firewall to allow FTP traffic on an Ubuntu server is an important task for maintaining a functional and secure file transfer service. To allow FTP traffic, users need to configure UFW to allow incoming and outgoing connections on the FTP ports.

Here’s a step-by-step guide to allowing FTP traffic through the firewall on Ubuntu 24.04:

1. Install UFW (If Not Already Installed)

Ubuntu has a firewall configuration tool which is famous as UFW. It simplifies the process of managing iptables rules:

sudo apt install ufw

2. Enable UFW

Now, enable UFW to start on boot as well as activate it via the following command:

sudo ufw enable

3. Allow FTP (Default Ports)

The standard port for FTP command control is 21, and for FTP data transfer, it is 20. For command control and data transfer, users need to allow FTP default ports as below:

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

4. Allow Passive Mode (Optional)

Additionally, if you’re using passive mode for FTP, users need to allow a range of high-numbered ports that the FTP server will use for data transfer. Let’s allow port range “10000:10100” with the specific range):

sudo ufw allow 10000:10100/tcp

5. Reload UFW

After allowing default or specific ports, users need to apply the changes via reloading UFW:

sudo ufw reload

6. Check UFW Status

Now, check the status of UFW to ensure the rules are applied:

sudo ufw status

7. Connect to the FTP Server (Verification)

Finally, users can connect the FTP server via the VSFTPD on Ubuntu 24.04 by mentioning the Server-IP-Address/hostname as below:

sudo ftp Server-IP-Address
sudo ftp username@Server’s-IP-Address
sudo ftp [system_name/hostname]

By following these steps, users configure the Ubuntu server’s firewall to allow FTP traffic successfully.

Step 2: Configuring VSFTPD

Configuring VSFTPD is the next step, which includes setting up local and anonymous user access, enabling file and folder uploads, and restricting local users to their home directory for added security. To configure VSFTPD on Ubuntu 24.04, follow the below steps:

1. Backup Configuration File

First, users need to back up the original configuration file with the “.orig” extension using the “cp” command:

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig

2. Configure VSFTPD

Open the configuration file for editing via the nano editor:

sudo nano /etc/vsftpd.conf

 

Make the necessary changes to the configuration file. Here are some common settings:

3. FTP Access (By Default Settings)

For setting up local user access or allowing local users to log in:

local_enable=YES

4. Enable Uploads

For enabling any form of FTP write command, uncomment this line for authenticated users to upload files:

write_enable=YES

5. Chroot jail (Limit User’s Access)

– To confine users to their home directories:

chroot_local_user=YES

6. Create a User List File

For creating a user list file, specify the “/etc/vsftpd.chroot_list” path to the “chroot_list_file” variable. Then, save and close the file:

7. Restart VSFTPD

For restarting VSFTPD to apply the changes:

sudo systemctl restart vsftpd

Step 3: Creating FTP Users

Creating a dedicated user for FTP operations enhances security; this user should not have sudo privileges and will be confined to a specific directory for file transfers. Let’s create FTP users on Ubuntu 24.04 as below:

1. Create a New User

The “sudo adduser <username>” command creates the user. Let’s create the “ftpuser” username. Then, set a strong password for the new user:

sudo adduser ftpuser

2. Create the Directory Structure (Optional)

Decide on the directory structure according to your organizational needs. For instance, you might want a separate folder for uploads, downloads, and shared files:

sudo mkdir -p /home/ftpuser/uploads
sudo mkdir -p /home/ftpuser/downloads
sudo mkdir -p /home/ftpuser/shared

3. Set Ownership and Permissions

Now, change the ownership of the directories to the FTP user and group:

sudo chown -R ftpuser:ftpuser /home/ftpuser

4. Set Appropriate Permissions for Each Directory (Optional)

Users can also set the appropriate permissions for each directory. For instance, make the uploads folder writable, the downloads folder read-only, and the shared folder both readable and writable.

sudo chmod 755 /home/ftpuser/downloads
sudo chmod 755 /home/ftpuser/shared
sudo chmod 777 /home/ftpuser/uploads

5. Configure the FTP Server

Now, modify/edit the FTP server configuration file to specify the root directory for the FTP user and set other necessary configurations by following Step 2.

If you’ve enabled “chroot_local_user”, ensure the user’s home directory is not writable by the user:

sudo chmod a-w /home/ftpuser

6. Restart the FTP Service

Finally, apply the changes by restarting the FTP service.

sudo systemctl restart vsftpd

Before testing the FTP Server, the user must find out the IP address using the “ip a” command:

ip a

Step 4: Testing the FTP Server

Finally, testing the FTP server setup using command-line tools or applications like FileZilla ensures that the server is functioning correctly and is ready for use.

1. Connect to FTP Server

From a remote computer, use an FTP client to connect to the server using the new user’s credentials.

Alternatively, users can also connect the FTP server via the VSFTPD on Ubuntu 24.04 by mentioning the Server-IP-Address/hostname as below:

sudo ftp Server-IP-Address
sudo ftp username@Server’s-IP-Address
sudo ftp [system_name/hostname]

2. Uploading or Downloading a File

Let’s try uploading or downloading a file to test write and read capabilities. For instance, download the “linuxgenie.cs” file successfully in the “/home/ftpuser” remote directory. In addition, users can also drag and drop the file:

Using Terminal

Alternatively, users can also upload/download files from the FTP server using the terminal. Let’s download the “linuxgenie.cs” file (already created one) from the FTP server as below:

get linuxgenie.cs # Download a file

put linuxgenie.cs # Upload a file

Bonus Tip: Securing the FTP Server

To further secure the FTP server, setting up SSL/TLS is advisable to encrypt the data transfer (secure data transmission). It can be achieved by generating SSL/TLS certificates and configuring the VSFTPD with these certificates. To set up an FTP Secure (FTPS) Server on Ubuntu 24.04, follow our guide on FTP Server on Ubuntu.

For more enhancement, regularly update your server and VSFTPD package. Also, use strong passwords and consider implementing user lockout policies.

This fully functional and secure FTP server runs on the Ubuntu 24.04 system.

Conclusion

To install/setup an FTP server on Ubuntu 24.04, update the packages list, and install “vsftpd” via the “sudo apt install vsftpd” command. Once installed, the service starts automatically. Finally, test the FTP access by logging in with the created user credentials and uploading, downloading, and accessing the shared files.

Remember, while FTP is a robust protocol, it’s always important to consider modern alternatives like SFTP for secure file transfers, especially when dealing with sensitive data. This guide has explained the step-by-step procedure to set up an FTP server with VSFTPD on Ubuntu 24.04.

Categories