How to install an FTP Server

sudo apt update && sudo apt install vsftpd
vsftpd.service - vsftpd FTP server
     Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-04-27 19:35:30 IST; 13s ago
   Main PID: 54532 (vsftpd)
      Tasks: 1 (limit: 1137)
     Memory: 652.0K
     CGroup: /system.slice/vsftpd.service
             └─54532 /usr/sbin/vsftpd /etc/vsftpd.conf
 
Apr 27 19:35:30 ubuntu systemd[1]: Starting vsftpd FTP server...
Apr 27 19:35:30 ubuntu systemd[1]: Started vsftpd FTP server.'
sudo ufw allow 20/tcp
sudo ufw allow 40000:50000/tcp
sudo ufw allow 40000:50000/tcp
sudo ufw allow 990/tcp
sudo adduser ftpuser
sudo usermod -d /var/www ftpuser
sudo chown ftpuser:ftpuser /var/www/html

Configure vsftpd

sudo mv /etc/vsftpd.conf /etc/vsftpd.conf.bak
sudo nano /etc/vsftpd.conf
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
allow_writeable_chroot=YES
sudo systemctl restart vsftpd

Now, if this was purely to just upload files we can stop here, however, normally you want to FTP a site that is for the web, so we need to be able to have the FTP user/group work in tandem with the www-data user/group.

So, here is what is needed:

sudo groupadd www-pub
usermod -a -G www-pub ftpuser
 
usermod -a -G www-pub www-data
sudo groups ftpuser
 
sudo groups www-data
sudo chown -R root:www-pub /where/your/web/directory/is
sudo chmod 2775 /where/your/web/directory/is

Then you should be able to FTP to a site without changing permissions all over the place!