Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed this guide { } to setup another user (joeuser) in the www-data group, but the unmask isn't being set in spite of these changes. The folder under /var/www/ is now owned by www-data group, but only www-data user can modify it. I have followed and re-followed every step mentioned in that howto.

I uncommented the echo statement in the below script:

#/bin/echo `/bin/date` > /tmp/sftp-test.txt
#/bin/echo 'Starting SFTP server from wrapper script to set correct umask...' >> /tmp/sftp-test.txt
umask 0002;

But nothing is being echoed / logged. I guess that means the script isn't being run. Now how can I trace what's happening when joeuser is logging in? The server is running Ubuntu 11.4.

share|improve this question

You are correct that this does indicate the script is not being run at all, which means the umask is not being set, so the file/folders will not be created with the correct permissions.

Is this on an Ubuntu system?

Could you post the output of ls -l /usr/lib/openssh/ and cat /etc/ssh/sshd_config | grep Subsystem

Update: I actually got this to work by renaming the sftp-server to sftp-server.orig and then creating a script named sftp-server with this in it:

umask 002

Be sure to chmod +x. I also restarted the ssh service, but that was probably not necessary in this case.

I did find out, though, that openssh 5.4 has an option for setting sftp umask, so there may be a less hackish way to do this in the future, but the Ubuntu Lucid server I tried this on was at version 5.3.

Also, I connected using a laptop with Ubuntu Maverick using the Nautilus sftp client. It would create directories with the proper umask, but it would NOT create files with the correct umask. I suspect this is an issue with the Nautilus client forcing the umask on the created files, and may work correctly if using a client such as filezilla or winscp. Update: I just verified that files copied up using winscp do have the correct file permissions. That is unfortunate about the Nautilus sftp client.

You might also try something like this:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.