Solved

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

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix Question 19 53
What is the meaning of mount pont? with respect to windows file server. 7 69
Problem logging tar errors 11 69
Linux hostname change 2 87
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
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 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…
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…

740 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