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.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this communityWe 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.
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
Subsystem sftp internal-sftp
.
– underscore_d
Oct 9 '15 at 12:27
In /etc/ssh/sshd_config, change the following:
Subsystem sftp /usr/lib/openssh/sftp-server
to:
Subsystem sftp /bin/sh -c 'umask 0002; exec /usr/libexec/openssh/sftp-server'
Soure: http://jeff.robbins.ws/articles/setting-the-umask-for-sftp-transactions
exec
before the final /usr/.../sftp-server
, so that you won't have useless sh
processes lying around.
– user1686
Jun 13 '10 at 20:32
umask
command doesn't need any leading zeroes, it always reads the argument as an octal number.) ... But on the second thought, maybe 0002
is clearer to understand.
– user1686
Jun 19 '10 at 20:52