Linux – SFTP server write permissions for group

linuxpermissionssftpsshvsftpd

I know there are a lot of questions on this, but nothing worked for me.
So I have a ftp server on Ubuntu 4.8 with sshd enabled. I would like to have write permissions for the group of the owner on every file uploaded.

Right now the permissions of the folder are: drwxrwxr-x
And every file uploaded have the permissions -rw-r--r--

What I have tried but doesn't change anything at all (using FileZilla 3.21.0 or sftpd command directly on Mac):

  • setting local_mask=0002 in /etc/vsftpd.conf
  • setting Subsystem sftp /usr/lib/openssh/sftp-server -u 002 or Subsystem sftp /usr/lib/openssh/sftp-server -u 0002 in /etc/ssh/sshd_config

I did restart vsftpd and sshd, but still have only read permissions for the group. What is the reason for this?

Best Answer

The SFTP protocol includes an operation for the client to set attributes for files on the server. This means that SFTP clients can set permissions on uploaded files, regardless of the umask.

I can think of three ways to accomplish what you want:

  1. Ask the remote user to set his client to disable setting permissions on uploaded files, assuming that's possible. For example, you can see a setting for that in this WinSCP dialog.

  2. Set up an automated process on the server to sweep the directory containing these files, and adjust permissions on any newly uploaded files.

  3. Disable the SSH_FXP_SETSTAT operation in the SFTP server. For the OpenSSH server, you'd have to alter the source code for the sftp-server program. There are commercial SSH/SFTP solutions on the market, and one of them may permit disabling this feature.