Install FTP Server on Ubuntu 20.04 | VSFTPD

hi in this article. I will show you how to install and configure vsf tpd server on ubuntu 2004.

 

Introduction

for this article. I am using ubuntu 2004 and vsf tpd. A very secure file transfer protocol daemon. let's start.

 

Install VSFTPD Server

Step1: let's begin by updating the package lists and installing vsf tpd open terminal.

Step2: to update the package lists type sudo apt update.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step3: the second command will then download and install vsf-tpd. Type sudo apt install vsf-tpd

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step4: press y and enter when asked to continue.

Step5: once installed check the status of vsf tpd with sudo service vsf tpd status. now we can see the FTP server is now up and running.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Configure Firewall

Step6: if you haven't already done so it is recommended that you enable the ufw firewall for ubuntu 2004. Now let's open ports 20 and 21 for FTP and ports 40 000 to 50 000 for passive FTP. we'll also open port 990 for tls with those commands. sudo ufw allow 20/tcp.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step7: type: sudo ufw allow 40000:50000/tcp

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step8: type: sudo ufw allow 990/tcp.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step9: type: sudo ufw enable

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step10: now make sure you add a rule for ssh otherwise you may get locked out of your server if you're connected remotely sudo ufw allow openssh.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step11: now enable the firewall with this command sudo ufw enable.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step12: check the status of ufw with sudo ufw status. if the firewall is running you should see the status as active and the firewall rules we just added.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Create FTP User

Step13: we will create a new user that we will use to log into FTP for example we will create a new user called FTP user by the command. sudo add user ftp user. generate a strong password and keep it safe now, we have two cases to configure the user FTP. the first one is to upload files directly to the home directory this one. I will show it the second one is for uploading files to the document root on the web server.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step14: now I ask you to focus more on this step and create a new directory called FTP in the user's home directory with the command sudo mkdir /home/ftpuser/ftp in this example our user is called FTP user.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step15: set the ownership of the FTP directory to nobody call in no group with sudo chown nobody:nogroup /home/ftpuser/ftp/

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step16: set permissions for the FTP directory using chmod so that it is not writable by anyone otherwise vsf tpd will not allow you to log in sudo chmod a-w /home/ftpuser/ftp. A-w means a=all, -= removed, w=write permission so remove right permissions for everyone.

Install FTP Server on Ubuntu 20.04 | VSFTPD
Install FTP Server on Ubuntu 20.04 | VSFTPD 

Step17: Next we will create a new directory within FTP where the user can view and upload files called files. sudo mkdir /home/ftpuser/ftp/files.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step18: assign ownership of this directory to our new FTP user otherwise they will not be able to write to it. sudo chown ftpuser:ftpuser /home/ftpuser/ftp/files/.

Install FTP Server on Ubuntu 20.04 | VSFTPD

VSFTPD Server Configuration

Step19: there are a few changes we have to make to the vsf tpd configuration file before you can start using FTP on ubuntu 2004 rename the config file sudo mv /etc/vsftpd.conf /etc/vsftpd.conf.origin. create a new config file sudo vi /etc/vsftpd.conf. you will find all the configuration lines below this step.

- sudo vi /etc/vsftpd.conf

Install FTP Server on Ubuntu 20.04 | VSFTPD
Install FTP Server on Ubuntu 20.04 | VSFTPD

listen=NO

listen_ipv6=YES

anonymous_enable=NO

local_enable=YES

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

force_dot_files=YES

pasv_min_port=40000

pasv_max_port=50000

Step20: we must tell vsf tpd that the local underscore route is the slash FTP folder we created earlier. we add those lines. user_sub_token=$USER local_root=/home/$USER/ftp. we are done with vsftpd.com.

Install FTP Server on Ubuntu 20.04 | VSFTPD

user_sub_token=$USER

local_root=/home/$USER/ftp

Step21: Save the file and exit.

Step22: restart vsf tpd. sudo systemctl restart vsftpd.service.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Test FTP Connection

Step23: We can now test vsf tpd to see. if we can log in as the user. we created earlier. we recommend Filezilla which works on windows mac and Linux.

Step24: enter your server's IP. your FTP username and password you created earlier and click quick connect.

Install FTP Server on Ubuntu 20.04 | VSFTPD

Step25: you will notice we have a warning in Filezilla status. insecure server it does not support FTP over tls. it is highly recommended that you now configure tls so that login credentials and traffic are encrypted over the FTP connection.

Install FTP Server on Ubuntu 20.04 | VSFTPD

thanks for reading this article. let me know what you think of this article in the comment section and don’t forget to share it with your friends.

Post a Comment

0 Comments