Link to home
Start Free TrialLog in
Avatar of dderton
ddertonFlag for United States of America

asked on

set umask for ssh accounts to set permissions correctly on files sent via sftp

I have a local account set up on a server and when I sftp files to that account the permissions are maintained from the original file.  However I would like to over ride those permissions and set a umask on the target server so if the original file has 644 I need them to be 664 on the target server.  I can't issue a "chmod" or run a script on the target server afterwards etc.  

This works today if I use plain ftp and set a umask in the users .profile on the target.  But we are being forced to switch to sftp instead and now I'm running into permission issues as ssh just keeps the same permissions on the original file which I have no control over.
Avatar of Joseph Gan
Joseph Gan
Flag of Australia image

Are you the owner of the origal files?
Can you change to 664 to the origibnal files before transfer ?
Umask is set within the .login, .profile depending on the user's shell .cshrc, .bashrc, .bash_profile
The source settings are not part of an information that the destination sees.

You can modify sshd configuration to mimic more of an FTP.
The issue is that the FTP server is likely configured with 022 as the umask.
https://www.experts-exchange.com/questions/28017145/centos-vsftpd-sftp-and-chroot-jailbreak.html
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dderton

ASKER

Works great.   Many thanks.