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:
sudo apt install vsftpd -y
We run it in the system:
sudo systemctl start vsftpd
sudo systemctl status vsftpd
systemctl enable vsftpd.service
We add a new user to the system:
sudo adduser testowyftp
We add to the program configuration:
echo "testowyftp" | sudo tee -a /etc/vsftpd.userlist
We create a directory for user files:
sudo mkdir -p /home/testowyftp/ftp_directory
sudo chown nobody:nogroup /home/testowyftp/ftp_directory
sudo chmod a-w /home/testowyftp/ftp_directory
sudo mkdir -p /home/testowyftp/ftp_directory/ftp_data
sudo chown testowyftp:testowyftp /home/testowyftp/ftp_directory/ftp_data
cd /home/testowyftp/ftp_directory/
chmod -R 777 ftp_data
We do a backup of the ftp configuration file
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
We edit the file and make changes:
nano /etc/vsftpd.conf
We will change as follows:
anonymous_enable=NO
local_enable=YES
Oraz ustawiamy w tym samym pliku:
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 and check the service:
sudo systemctl restart vsftpd
sudo systemctl status vsftpd
That's all, we should now log in correctly to ftp on the test user ftp.
the server for this guide was provided by statnet.pl https://www.statnet.pl/vps/root-vps/
We select Yes and click enter:
It works fine but: forget about securing the ability of the ftp client to enter the root directory after connecting via ftp, and this cannot be, because all system files are available. I'm going to change that , where to put DefaultRoot~ ??