How to add FTP to ServerPilot

When possible, you should use SFTP instead of http://FTP. That being said, sometimes you need FTP access.

This tutorial walks you through how to install and enable FTP on your ServerPilot installation.

Install vsftpd
Update firewall rules
Post install fixes
Bonus: allow remote access to other directories

Install vsftpd

apt-get update
apt-get -y install vsftpd

nano /etc/vsftpd.conf
Disable anonymous access:

Allow local users to login:

Allow users to write to a directory:

Jail (lock) users to their home directory:

Uncomment local_umask to make default permissions 755

Restart the FTP service:

service vsftpd restart
Update firewall rules

First you need to login into ServerPilot and disable their management of the firewall

Then you need to enable port 21:

sudo ufw allow 21/tcp
Post install fixes

When you try to connect via FTP, you might see the following error:

500 OOPS: vsftpd: refusing to run with writable root inside chroot().

Assuming we have a user named ftpuser:

1) Fix permission for ftpuser's home directory:

chmod a-w /home/ftpuser/
2) Now make a new directory to upload your files to:

mkdir /home/ftpuser/uploads
chown ftpuser:ftpuser /home/ftpuser/uploads
Bonus: allow remote access to other directories

Sometimes you want to grant the FTP user access to directories outside their home folder (for example, the www directory).

You can accomplish this by using the bind command (replace YOURAPP):

mount --bind /srv/users/serverpilot/apps/YOURAPP/public /home/ftpuser/www
This creates a folder named "www" in ftpuser's home directory.

You might need to update the folder's permission

chown ftpuser:ftpuser /srv/users/serverpilot/apps/YOURAPP/public
Finally, you'll want to make sure this binding occurs everytime the server starts. We can do this by updating the rc.local script:

nano /etc/rc.local
mount --bind /srv/users/serverpilot/apps/YOURAPP/public /home/ftpuser/www