As Internet is now growing like anything, various requirements / demands come across. recently i was setting up a web development server where multiple developers were required to add / edit / update files on same directory ….. hmmm .. Initially i thought i will create a group and add those developers in that group and everything will be done .. but as default UMASK on LINUX server is set to 0022, it dosen’t grant write permissions to group by default.. Hence I need to change UMASK to 0002 for those sftp users… and here you go ..There are multiple ways to achieve this .. first way to set up a shell script which will start sftp sub system with umask 0002 …
Create following shell script:
#!/bin/bash umask 0002 # The path to your sftp-server binary may differ exec /usr/libexec/openssh/sftp-server
Then I pointed the Subsystem directive in the sshd_config file to my script:
Subsystem sftp /opt/sftp-server-script.sh
A quick restart/reload of the sshd configuration and I was in business. Both users could see and edit each others files. Email or comment with questions.
—Second option :
Or even simpler still as @Gilles pointed out in the comments you can do away with the wrapper script entirely and simply change the Subsystem line in your sshd_config to this:
Subsystem sftp /bin/sh -c ‘umask 0002; /usr/libexec/openssh/sftp-server’
Thanks Mate… much appreciated.
There is a new flag for the sftp-server, ‘-u’, that allows you to directly set the umask, overriding the user umask. So to use it, just do this:
Subsystem sftp /usr/libexec/openssh/sftp-server -u 0002