FTP

How To Set Up vsftpd on Ubuntu 24.04

Welcome back to the Greenhost.Cloud blog! Today, we are diving into the world of FTP (File Transfer Protocol) by guiding you through the setup of vsftpd (Very Secure File Transfer Protocol Daemon) on Ubuntu 24.04. This powerful FTP server allows you to securely transfer files over the internet, and it’s known for its performance and security features.

Whether you’re looking to share files between servers or provide FTP access to users, this step-by-step guide will equip you with the knowledge necessary to get started.

What is vsftpd?

vsftpd is an open-source FTP server that is widely used due to its robust performance and strong security measures. It supports a variety of features, including anonymous FTP, virtual users, and SSL/TLS encryption.

Prerequisites

Before we proceed with the installation, ensure you have the following:

  1. A server running Ubuntu 24.04.
  2. A non-root user with sudo privileges.
  3. Basic familiarity with terminal commands.

Step 1: Update Your System

Start by updating your system’s package index to ensure you have the latest package information.

sudo apt update
sudo apt upgrade -y

Step 2: Install vsftpd

Now, let’s install vsftpd. Run the following command:

sudo apt install vsftpd -y

Once the installation is complete, you can check the service status with:

sudo systemctl status vsftpd

You should see an output indicating that the service is running.

Step 3: Configure vsftpd

The main configuration file for vsftpd is located at /etc/vsftpd.conf. Before modifying it, it’s a good idea to back it up:

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

Now, open the configuration file in your preferred text editor. We will use nano for this example:

sudo nano /etc/vsftpd.conf

Basic Configuration Changes

You may want to make the following changes to the configuration file:

  1. Enable Anonymous Access (Optional):
    If you intend to allow anonymous users to connect, ensure the following line is set:
   anonymous_enable=YES

For security reasons, it’s generally recommended to disable anonymous access by setting it to NO.

  1. Enable Local Users:
    Allow local users to log in:
   local_enable=YES
  1. Enable Uploading Files:
    Allow users to upload files:
   write_enable=YES
  1. Chroot Local Users:
    This will ensure that users are confined to their home directories:
   chroot_local_user=YES
  1. Set a User List (Optional):
    Define which users can use FTP (you can create a separate list).
   userlist_deny=NO
   userlist_file=/etc/vsftpd.userlist
  1. Enable Logging (Optional but recommended):
    Create logs for FTP activities:
   xferlog_enable=YES

After making the necessary changes, save the file and exit the editor.

Step 4: Restart vsftpd Service

To apply the changes, restart vsftpd:

sudo systemctl restart vsftpd

Step 5: Configure Firewall

If you have a firewall enabled (e.g., UFW), make sure to allow FTP traffic. Enable the FTP service with the following command:

sudo ufw allow from any to any port 21

To enable passive mode (often needed), you may want to allow a range of ports:

sudo ufw allow 40000:50000/tcp

Reload the UFW to apply the changes:

sudo ufw reload

Step 6: Create FTP User (Optional)

If you need to create a dedicated FTP user, you can do so with the following command:

sudo adduser ftpuser

This command will prompt you to set a password and provide additional user details.

If you chose to set up a user list earlier, add your new FTP user to the list by appending the username into the /etc/vsftpd.userlist file:

echo "ftpuser" | sudo tee -a /etc/vsftpd.userlist

Step 7: Testing the FTP Server

To test the FTP server, you can use any FTP client or command line. To connect via command line, use:

ftp your_server_ip

If everything was configured correctly, you should be able to log in using the credentials of either the FTP user you created or any local user that has access.

Conclusion

Congratulations! You have successfully set up vsftpd on Ubuntu 24.04. You can now securely transfer files over FTP. This guide just scratches the surface of what vsftpd can do. For advanced configurations, such as SSL/TLS encryption and virtual users, refer to the official vsftpd documentation.

As always, stay secure and check back for more insightful posts from Greenhost.Cloud!

Happy FTP-ing!