Solved

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

Posted on 2013-02-04
4
1,568 Views
Last Modified: 2013-02-06
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
Comment
Question by:dderton
4 Comments
 
LVL 16

Expert Comment

by:Joseph Gan
ID: 38853389
Are you the owner of the origal files?
Can you change to 664 to the origibnal files before transfer ?
0
 
LVL 76

Expert Comment

by:arnold
ID: 38853393
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
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 38854242
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
 

Author Closing Comment

by:dderton
ID: 38861847
Works great.   Many thanks.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now