Installing vsftpd on a Debian system 11
The following guide describes how to install ftp vsftpd server in Debian system 11.
We will do everything from the terminal by executing a few simple commands.
The first step is to run the terminal or log in to our server via ssh and install:
1 | sudo apt install vsftpd -y |
Run it on your system:
1 | sudo systemctl start vsftpd |
1 | sudo systemctl status vsftpd |
1 | systemctl enable vsftpd.service |
We add a new user to the system:
1 | sudo adduser testowyftp |
We add to the program configuration:
1 | echo "testowyftp" | sudo tee -a /etc/vsftpd.userlist |
We create a directory for user files:
1 | sudo mkdir -p /home/testowyftp/ftp_directory |
1 | sudo chown nobody:nogroup /home/testowyftp/ftp_directory |
1 | sudo chmod a-w /home/testowyftp/ftp_directory |
1 | sudo mkdir -p /home/testowyftp/ftp_directory/ftp_data |
1 | sudo chown testowyftp:testowyftp /home/testowyftp/ftp_directory/ftp_data |
1 | cd /home/testowyftp/ftp_directory/ |
1 | chmod -R 777 ftp_data |
We do a backup of the ftp configuration file
1 | sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak |
We edit the file and make changes:
1 | nano /etc/vsftpd.conf |
We will change as follows:
1 2 3 | anonymous_enable=NO local_enable=YES |
And we set it in the same file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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 |
We reload the ftp server:
1 | sudo systemctl restart vsftpd |
The last step is to add the port 21 to the firewall
1 2 3 4 5 | sudo ufw allow 21/tcp sudo ufw allow 22/tcp sudo ufw reload |
That's all, we should now log in correctly to ftp on the test user ftp