Background information:

I'm using Serverpilot to manage my Ubuntu server which doesn't provide any FTP service.

  • There is a user: serverpilot
  • With the home directory: /srv/users/serverpilot/
  • And there is a website running in this directory: /srv/users/serverpilot/apps/website/public/.

What I want:

Now I would like to have a FTP account which can only read and write to this directory: /srv/users/serverpilot/apps/website/public/ftpdir/.

What I've tried:

  • I've installed vsftpd: sudo apt-get install vsftpd
  • Created a new user with that directory as home: sudo useradd -m -d /srv/users/serverpilot/apps/website/public/ftpdir ftpuser (wich is probably not a good idea to have a home directory of a user in another users home directory)
  • I've changed the password with sudo passwd ftpuser
  • Edited the default vsftpd configuration with sudo vi /etc/vsftpd.conf
    • local_enable=YES so the ftpuser can be used as ftp login
    • write_enable=YES the user is able to write
    • chroot_local_user=YES can't access anything outside it's home dir
    • pam_service_name=ftp because I was getting a 530 Login incorrect error
  • And opened my firewall with: sudo ufw allow 21/tcp

The problems:

  • Other users beside the ftpuser can also be used as FTP login. I just want to have 1 ftp user and not allow other system users to use FTP.
  • The ftpuser can also SSH into the server.
  • I'm getting a 553 error: could not create file error when trying to upload a file, to fix this I came across this question: https://askubuntu.com/a/320186 but I don't think this is the right way because the file should be owned by the serverpilot user, not the ftpuser user. The website running under the serverpilot user should proces the uploaded files.

How I've solved it before:

In the past on another server I've changed the directory ownership and after adding these extra vsftpd configuration options it was finally working:


But on that server I had problems with processing the uploaded files because of the ownership, so there I'm using the file_get_contents() PHP function to get the files over the web instead of direct access them on the server which isn't that nice.

The final question:

How can I simply have 1 ftp login which can read and write to a directory in a users home directory where the ownership stays on the user where the home directory is from?

Sorry for the duplication, I've also asked this question on Ask Ubuntu without any answer: https://askubuntu.com/questions/774701/ftp-account-for-just-one-directory maybe more luck over here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.