In this tutorial, we will show you how to install FTP Server on Debian 11. For those of you who didn’t know, FTP is a standard network protocol used for transferring files between computers over a network. It operates on a client-server model, where the client initiates a connection to the server and requests file transfers. FTP servers play a vital role in various domains, including web development, file sharing, and system administration.
In web development, FTP servers enable developers to upload and manage website files on remote servers. This streamlines the deployment process and facilitates collaboration among team members. File sharing is another common use case, where FTP servers provide a centralized location for users to access and exchange files securely.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the FTP Server on a Debian 11 (Bullseye).
Prerequisites
- A server running one of the following operating systems: Debian 11 (Bullseye).
- It’s recommended that you use a fresh OS install to prevent any potential issues
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install FTP Server on Debian 11 Bullseye
Step 1. First, update your package lists to ensure you have the latest information on available packages:
sudo apt update sudo apt upgrade sudo apt install gnupg2
Step 2. Installing FTP Server on Debian 11.
By default, Vsftpd is available on the Debian 11 base repository. Now run the following command below to install Vsftpd to your Debian system:
sudo apt install vsftpd
Once the installation is complete, now enable Vsftpd (to start automatically upon system boot), start the web server, and verify the status using the commands below:
sudo systemctl start vsftpd sudo systemctl enable vsftpd sudo systemctl status vsftpd
Step 3. Create FTP user.
Now create the FTP user for the vsftp.userlist
file. Local users specified in this file are granted permission to access the FTP server:
sudo adduser meilana
Next, we need to add meilana user in vsftpd user list:
echo "meilana" | sudo tee -a /etc/vsftpd.userlist
After that, create an FTP directory:
sudo mkdir -p /home/meilana/ftp_directory sudo chown nobody:nogroup /home/meilana/ftp_directory sudo chmod a-w /home/meilana/ftp_directory
Then, create a directory where files can be uploaded and give ownership to meilana user by executing the command:
sudo mkdir -p /home/meilana/ftp_directory/ftp_data sudo chown meilana:meilana /home/meilana/ftp_directory/ftp_data cd /home/meilana/ftp_directory/ chmod -R 777 ftp_data
Step 4. Configure the FTP server.
Now we must proceed and edit the main configuration file /etc/vsftpd.conf
:
nano /etc/vsftpd.conf
Modify the following file:
listen=NO listen_ipv6=YES anonymous_enable=NO write_enable=YES local_umask=022 dirmessage_enable=YES use_localtime=YES xferlog_enable=YES connect_from_port_20=YES chroot_local_user=YES secure_chroot_dir=/var/run/vsftpd/empty pam_service_name=vsftpd user_sub_token=$USER local_root=/home/$USER/ftp_directory userlist_enable=YES userlist_file=/etc/vsftpd.userlist userlist_deny=NO
Restart the server for the changes to take effect:
sudo systemctl restart vsftpd
Step 5. Secure Vsftpd using SSL.
To provide a secure FTP connection to the server, we need to encrypt the server using an SSL certificate:
sudo mkdir /etc/cert sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/cert/vsftpd.pem -out /etc/cert/vsftpd.pem
Next, edit vsftpd.conf
file and make some changes:
nano /etc/vsftpd.conf
Add the following line:
rsa_cert_file=/etc/cert/vsftpd.pem rsa_private_key_file=/etc/cert/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
Save and exit the file, then restart Vsftpd using the following command below:
sudo systemctl restart vsftpd
Step 6. Configure Firewall.
Now we have to configure the firewall so that the FTP traffic can pass through the firewall:
sudo ufw allow 21/tcp sudo ufw allow 22/tcp sudo ufw reload
Step 6. Accessing the FTP server on Debian.
To test the FTP connection, you will need to install an FTP client in the same or a separate system from where you want to access the FTP server. In our case, we are using FileZilla as an FTP client.
Step 7. Troubleshooting.
- Permission Errors
If you encounter permission errors, ensure the FTP directory and files have the correct ownership and permissions. Use the chown and chmod
commands to adjust them as needed.
- Firewall Blocking FTP Ports
Ensure your firewall allows FTP traffic. Use the following commands to open the necessary ports:
sudo ufw allow 20/tcp sudo ufw allow 21/tcp
- Failed User Authentication
If user authentication fails, verify the username and password. Ensure the user is listed in the /etc/vsftpd.userlist
file and that the vsftpd service is running.
Congratulations! You have successfully installed FTP Server. Thanks for using this tutorial for installing the latest version of the FTP Server on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official Vsftpd website.