FTP is used to transfer files from one host to another over TCP network. This article explains how to setup FTP server on ubuntu 16.04. There are 3 popular FTP server packages available PureFTPd, VsFTPD and ProFTPd. Here i’ve used VsFTPD which is most secure. I’ll be logged in as root.
Setup vsFTPd server on Ubuntu 16.04
Step 1 – Update repositories.
Step 2 – Install VsFTPD
Step 3 – Backup config file
Step 4 – Open config file with follow command.
Step 5 – Configration of vsFTPd file – Open /etc/vsftpd.conf file and search with Ctrl+W and make changes as it is shown below. Remove commends if they exist or add missing line.
Step 6 – Configration of vsFTPd file – Allow access only for certain users.
Step 7 – Create /etc/vsftpd.allowed_users
Step 8 – Include users who should have access in /etc/vsftpd.allowed_users
Step 9 – If you want, you can make Advanced Configuration
#Hide the info about the owner (user and group) of the files.
#Maximum number of clients:
#Connection limit for each IP:
#Chnage listen port from 21 to other
Step 10 – Add ftp user and change home directory for this user. This is very important because you will restrict the user to access to one directory. You can allow access to /var/www/ and the user will have access to all folders on your sites or choose to access to only one site. For example if you want to create ftp user and to allow him to access to only one site, write the following commands. And don’t forget to add new user in /etc/vsftpd.allowed_users
root@mail:/# usermod –home /var/www/YOURFOLDERSITE ftp
or open this file /etc/passwd and search user which you want to change home directory. Change /home/ftpuser with /vat/www.
root@mail:/# ftpuser:x:1001:1001:FTP USER,,,:/var/www:/bin/bash
Step 11 – Restart vsFTPd – You must restart vsFTPd service for the changes to take effect. Now when user connect via ftp with filezilla he will see only one folder from your sites.
If you want to see output from command you ca execute this command /etc/init.d/vsftpd restart
Step 12 – Show vsftpd status with systemctl status vsftpd
Step 13 – Configuration of permissions – If you want everybody to have a permission to write in this folder, you have to set full permission 777. If you want only the ftp group to have permission to write and everyone else to have permission only to read, you have to set a permission 775.
root@mail:/# chown ftp:ftp -R /var/www/YOURFOLDERSITE