Ubuntu SSH – How to Set Default Permissions for SFTP

permissionssftpsshUbuntuumask

We have an Ubuntu 10.04 server. How can I set it so that new files created (or copied) over SFTP or SSH have g+rw and g+rwx permissions (where appropriate)?

I'm also using setgid (chmod g+s) so that they inherit the proper group owner.

Best Answer

In /etc/ssh/sshd_config, you can pass a flag and value in (-u 0002) like the following to set the umask value:

Subsystem sftp /usr/lib/openssh/sftp-server -u 0002

Append the -u 0002 to the existing Subsystem sftp line of the configuration file.

Afterwards, you will need to restart ssh for the changes to take effect:

service ssh restart