Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ssh , scp umask 1

Status
Not open for further replies.

felix001

Technical User
Nov 15, 2008
102
GB
For the love of God, does anyone know how to set the umask of SSH and in turn scp.
I have tried every thing..... the various files in the ssh profile... the adding of umask in the config files, hopping on one leg, and even as a last resort dressing up as elvis and performing a juggling act whilst on a uni cycle...

[root@localhost .ssh]# pwd
/root/.ssh
[root@localhost .ssh]# ls -l
total 16
-rwx------ 1 root root 19 Apr 25 16:11 environment
-rw-r--r-- 1 root root 3837 Apr 25 15:48 known_hosts
-rwxr-xr-x 1 root root 19 Apr 25 16:08 rc
[root@localhost .ssh]# cat environment rc
/usr/bin/umask 755
/usr/bin/umask 755
[root@localhost .ssh]#

 
felix001,

Does your sshd_config file have the "PermitUserEnvironment" setting?

Without that, the .ssh/environment file is ignored.

--
ZaSter


 
In the not too distant past, I had need to do basically the same thing for sftp - control the umask. Here are the steps I followed for sftp (I didnt test with scp, but the principle is the same):

1.) create a script called sftp_server.sh (or any name that you want. It should contain the following:

Code:
#!/bin/ksh
umask 007
exec /path/to/sftp-server

Note: a umask of 007 will result in a file created with permissions that look like this:

Code:
-rw-rw----  1 joe user    0 Apr 28 15:36 file.junk

Make sure to do a chmod 755 on the script.


2.) look in your sshd_config file. You should see a line similar to this (usually at/near the end of the file):

Code:
Subsystem       sftp    /usr/libexec/sftp-server

change this line so it looks something like this:

Code:
Subsystem       sftp    /some/path/to/sftp_server.sh

3.) Restart ssh daemon (various methods, choose your preferred way)

4.) Test. Your files should be created with the specified umask.


Add a little color to your PUTTY terminal: faq52-6627
 
This worked a treat, thanks for your help.....

:)
 
Felix - if it worked a treat then surely sbrews solution is deserving of a little purple star in appreciation?

Some days are diamonds, some days are rocks - make sure most are the former.
 
I agree, the purple star has been given..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top