I'm using Serverpilot to manage my Ubuntu server which doesn't provide any FTP service.
- There is a user:
- With the home directory:
- And there is a website running in this directory:
What I want:
Now I would like to have a FTP account which can only read and write to this directory:
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
ftpusercan be used as ftp login
write_enable=YESthe user is able to write
chroot_local_user=YEScan't access anything outside it's home dir
pam_service_name=ftpbecause I was getting a 530 Login incorrect error
- And opened my firewall with:
sudo ufw allow 21/tcp
- Other users beside the
ftpusercan also be used as FTP login. I just want to have 1 ftp user and not allow other system users to use FTP.
ftpusercan also SSH into the server.
- I'm getting a
553 error: could not create fileerror 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
serverpilotuser, not the
ftpuseruser. The website running under the
serverpilotuser 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:
file_open_mode=0775 local_umask=022 allow_writeable_chroot=YES pam_service_name=vsftpd
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