How can I change the umask for ssh and sftp in debian squeeze.

I have changed the umask from 022 to 002 in  
/etc/profile and  
and modified 
Subsystem sftp /usr/lib/openssh/sftp-server to 
Subsystem sftp /usr/lib/openssh/sftp-server -u 002
in /etc/ssh/sshd_config 

Everything seems to work when I am connecting through a shell, but I am still getting the wrong permissions when uploading files with through . Do you have any idea of how I can fix that issue?

I manged to solve the issue by following How to setup ssh's umask for all type of connections

# Setting UMASK for all ssh based connections (ssh, sftp, scp)
session    optional     pam_umask.so umask=0027
in /etc/pam.d/sshd
and /etc/pam.d/login

I also reverted to 
Subsystem sftp /usr/lib/openssh/sftp-server 
in /etc/ssh/sshd_config

1 Answer 1


Create a wrapper script which sets the correct umask and execute that as instead of sftp

umask 002
exec /usr/lib64/misc/sftp-server

Modify the sshd_config

Subsystem       sftp    /usr/local/sbin/sftp-server.sh

Your sftp-server location may vary.

  • Thank you for the answer. I managed to solve the issue before you got to answer so I am giving you and upvote for the effort. Thanks for helping out but I am not going to try your solution since I already got it to work. (I had to few points to give you an upvote :( sorry)
    – user68802
    May 20, 2011 at 7:17
  • @user68802 What's your final solution then? You should add it here. Jun 25, 2014 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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