Solved

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

Posted on 2013-02-04
4
1,817 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 79

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.
Suggested Courses

615 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