Linux – Set default umask for everything in Debian Squeese, included sftp

debian-squeezelinuxpermissionssshumask

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  
/etc/login.defs 
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

Added:
# 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

Best Answer

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

#!/bin/bash
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.