Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2092
  • Last Modified:

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.
0
dderton
Asked:
dderton
1 Solution
 
Joseph GanSystem AdminCommented:
Are you the owner of the origal files?
Can you change to 664 to the origibnal files before transfer ?
0
 
arnoldCommented:
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.
http://www.experts-exchange.com/Security/Operating_Systems_Security/Linux/Q_28017145.html
0
 
woolmilkporcCommented:
Set the sftp umask in like this:

- On the target server change in /etc/ssh/sshd_config (or maybe /etc/sshd_config)

Subsystem sftp /opt/openssh/libexec/sftp-server

to

Subsystem sftp /opt/openssh/libexec/sftp-server -u 002

The above should work with "internal-sftp", too.

Restart sshd and you're done.
0
 
ddertonAuthor Commented:
Works great.   Many thanks.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now