Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

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 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
share|improve this question

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/

Your sftp-server location may vary.

share|improve this answer
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 '11 at 7:17
@user68802 What's your final solution then? You should add it here. – Vasilis Lourdas Jun 25 '14 at 6:04

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.