DebianLinuxTutorials

How To Install FTP Server on Debian 11

Install FTP Server on Debian 11

In this tutorial, we will show you how to install FTP Server on Debian 11. For those of you who didn’t know, The vsftpd FTP Server is one of the most trusted applications among Linux professionals. The official website of vsftpd FTP Server claims that security, stability, and performance are the key points due to which it has gained much popularity among Linux users.

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 through 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 the root user. We recommend acting as a non-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. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade
sudo apt install gnupg2

Step 2. Installing FTP Server on Debian 11.

By default, Vsftpd is available on 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 webserver, 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 to 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 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.

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.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button