Ubuntu – How to allow a vsftpd to write to a folder other than default `/files`

ftppermissionsUbuntuvsftpd

I'm new to FTP and I've been following this DigitalOcean tutorial.

Everything works great except that a user (at least in FileZilla) cannot write to the root of his /home/user/ftp folder, only /home/user/ftp/files. An attempt to create in the root folder results in:

Command: PASV
Response: 227 Entering Passive Mode (104,131,29,61,191,224).

Command: STOR asdfa

Response: 553 Could not create file.

Error: Critical file transfer error

I scanned /etc/vsftpd.conf file for the word files but I can't find that config anywhere. I've used FTP before and generally you drop and and the files are right there, without needing to navigate to folders.

Is this a chown problem of some sort in Ubuntu?

Is it possible to just allow a user to write to root and if so, how?

Best Answer

Your default /etc/vsftpd.conf doesn't initially include all the possible directives the configuration file supports. The rest can be found from man vsftpd.conf.

Answer to your question can be found in the very tutorial you are following:

FTP is generally more secure when users are restricted to a specific directory. vsftpd accomplishes this with chroot jails. When chroot is enabled for local users, they are restricted to their home directory by default. However, because of the way vsftpd secures the directory, it must not be writable by the user. This is fine for a new user who should only connect via FTP, but an existing user may need to write to their home folder if they also shell access.

In other words, you have created the /home/user/ftp folder to allow vsftp use chroot jails without making the home folder /home/user/ read only to the user. Therefore you are already doing best practices and should not be worried about the error as it is normal and desired behaviour.

It is possible but highly not recommended to disable chroot jail.

If this is only about enchanging the user experience, you could try append directly to /home/user/ftp/files after login by adding/modifying vsftp.conf directives:

user_sub_token=$USER
local_root=/home/$USER/ftp/files