I know this question has been already discussed, but by reading the posts I could not figure the answers, because some said "yes umask can work", and others say "OpenSSH put command always preserve permissions"
Before all just to precise:
- I use OpenSSH 5.9 on RHEL 6.2
- I have configured a chrooted SFTP server, using
internal-sftpsubsystem, with-u 0002for umask - I precise I don't use the
-por-Poption
From what I have read on one hand: there are many ways to define umask for SFTP transfers:
- option
-uofinternal-sftp(orsftp-server) , since OpenSSH 5.4 - create a wrapper to
sftp-server(in which we explicitly set the umask - this doesn't fit for chrooted environment btw) - add a specific configuration in
pam.d/sshdfile
On the other hand I have read:
The OpenSSH SFTP client and server do transfer the permissions (as an extension) and create the remote file with the permissions on the local side. AFAICT, there is no way to disable this behavior.
So I did the following test:
On my client I created file MYFILE and directory MYDIR with permissions 600 and 700.
Then with sftp commands:
mkdir => the new directory has permissions following the umask (OK)
put MYFILE => MYFILE has same permissions as on client (KO)
put -r MYDIR => MYDIR has same permissions as on client (KO)
If I change permissions of MYFILE and MYDIR on client side, and upload again, I get the new permissions on server side.
I tried the pam.d solution too, but it changed nothing.
So now I'm confused :
From what I tested and a part of what I read, I would say OpenSSH always preserve permissions. But as there are many posts saying that a umask could be defined, I can imagine I do a wrong thing in my test configurations.
I would appreciate some experienced feedback.
Thank you.