Solved

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

Posted on 2013-02-04
4
1,614 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 77

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

867 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

15 Experts available now in Live!

Get 1:1 Help Now