Create new ftp user

useradd -m -d /home/sarah sarah
passwd sarah

Give password: 575757aA

usermod -g www-data sarah

Add user to vsftpd

cd /etc/vsftpd
nano sarah
local_root=/var/www/sarah/public_html
htpasswd -cd /etc/vsftpd/ftpd.passwd sarah

Will ask for password now

575757aA

Then edit user home directory (not sure if this is actually needed anymore)

usermod --home /var/www/sarah/public_html sarah

Check that user can write to directory

sudo chown -R sarah:www-data /var/www/sarah/public_html
chmod 775 /var/www/sarah/public_html
/etc/init.d/vsftpd restart

For changes to take effect restart apache

service apache2 restart

Try connecting to FTP using FTP user, password and port 21

Need port 21 because WordPress doesn’t allow changing of ports

Install vsftpd

Step 1: Installation

Run the following command to install vsftpd:

apt-get install vsftpd

Step 2: Configuration

Open up the configuration file using your text editor of choice. This example uses vim.

nano /etc/vsftpd.conf

Copy these

#listen=NO
anonymous_enable=YES
local_enable=YES
write_enable=YES
#local_umask=022
local_umask=002
#dirmessage_enable=YES
#chroot_local_user=YES
#pam_service_name=vsftpd
pam_service_name=ftp

Add to end:

#Google Compute config
pasv_min_port=5000
pasv_max_port=6000

#Wordpress FTPS config
#allow_anon_sll=NO
#force_local_data_ssl=YES
#force_local_logins_ssl=YES
#ssl_tlsv1=YES
#ssl_sslv2=NO
#ssl_sslv3=NO
#require_ssl_reuse=NO
#ssl_ciphers=HIGH
listen_port=21

Save the file and close your text editor. Then, start vsftpd as a daemon:

service vsftpd start

At this point, you can log in your ftp server from your local computer.

Extras

If you want to prevent all local users from leaving their home directory, you need to uncomment this line from /etc/vsftpd.conf:

chroot_local_user=YES

As of vsftpd 2.3.5, the chroot directory must not be writable. You can change the permissions of this folder with the following command:

chmod a-w /home/user

Remember to restart the vsftpd daemon after editing vsftpd.conf.

service vsftpd restart