How to install an FTP server on Ubuntu 22.04 with VSFTPD

File transfer is an essential component of many IT infrastructures, whether for sharing files between colleagues, distributing software updates or backing up data. To facilitate this process, the use of an FTP (File Transfer Protocol) server is often preferred for its simplicity and reliability. In this article, we’ll show you how to install and configure an FTP server on your Ubuntu 22.04 system using VSFTPD (Very Secure FTP Daemon).

VSFTPD installation

Update the system :

sudo apt update & sudo apt upgrade

Install VSFTPD :

sudo apt install vsftpd

Once the installation is complete, VSFTPD will be operational on your Ubuntu system.

Check VSFTPD operation:

sudo service vsftpd status

Enable VSFTPD autostart :

sudo systemctl start vsftpd

sudo systemctl enable vsftpd

VSFTPD configuration

VSFTPD is mainly configured via the /etc/vsftpd.conf configuration file.

See also: Installing Virtualmin on an Ubuntu 22.04 server

You can use your favorite text editor to open this file and customize the settings to suit your needs.

Here are some common settings you may want to configure:

  • anonymous_enable: Enable or disable anonymous access to the FTP server.
  • local_enable: Enable or disable local user access to the FTP server.
  • write_enable: Enables or disables writing of files to the FTP server.
  • chroot_local_user: Restricts local users to their home directory.
sudo nano /etc/vsftpd.conf

Change files to :

local_enable=YES
write_enable=YES
chroot_local_user=YES

Add these lines to the end of the :

user_sub_token=$USER
local_root=/home/$USER/ftp
pasv_min_port=10000
pasv_max_port=10100
userlist_enable=YES
userlist_file=/etc/vsftpd.userlist
userlist_deny=NO

Now restart VSFTPD :

sudo systemctl restart vsftpd.service

FTP user management

You can create new FTP users using the adduser or useradd command and grant them access to the FTP server by modifying the /etc/vsftpd.userlist file.

sudo adduser utilisateur

sudo mkdir -p /home/utilisateur/ftp

sudo chown nobody:nogroup /home/utilisateur/ftp

sudo chmod a-w /home/utilisateur/ftp

sudo mkdir /home/utilisateur/ftp/fichiers

sudo chown utilisateur:utilisateur /home/utilisateur/ftp/fichiers

sudo nano /home/utilisateur/ftp/fichiers/liste.txt

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

sudo systemctl restart vsftpd

Configure firewall

If your server uses the ufw firewall, allow certain ports:

sudo ufw allow 20:21/tcp
sudo ufw allow 10000:10100/tcp

Securing VSFTPD

To enhance the security of your FTP server, you may want to consider using features such as SSL/TLS encryption, access control lists (ACLs) and firewalls to restrict access to the FTP server.

Use the following command:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem

Add the following lines to /etc/vsftpd.conf

rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
require_ssl_reuse=NO
ssl_ciphers=HIGH
pasv_min_port=40000
pasv_max_port=50000

Conclusion

By following this guide, you’ve learned how to install, configure and secure a working FTP server on your Ubuntu 22.04 system using VSFTPD.

Whether you want to transfer files locally or over the Internet, VSFTPD offers a reliable and secure solution to your file transfer needs.

Don’t forget to consult the official VSFTPD documentation for more detailed information on the configuration and advanced use of the FTP server.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.