Friday, February 15, 2013

linux scp and umask

I use CentOS 5.x
The problem is that if I use scp or sftp to copy a file on such CentOS server, the umask is not taken in consideration.
Behavior of scp and sftp is different.

Btw, a solution is to use openssh 5, but I don't like to alter the distribution, since CentOS 5 install openssh 4.

Using google I've found different solution (pam? etc.) but no one works for me.

So, a way to make what I want is:

For sftp

vi /etc/ssh/sshd_config
# override default of no subsystems
# Subsystem       sftp    /usr/libexec/openssh/sftp-server
Subsystem sftp /bin/sh -c 'umask 0002; /usr/libexec/openssh/sftp-server'

and restart sshd

And for scp

vi /home/myuser/.bashrc

adding (0002 or what you want)

umask 0002

1 comment:

  1. Thank you for Sharing Nice Guide ,

    Could i copy a single file to multiple server at a time Using a SINGLE command ??
    I don't want to make any scripts. Sir Is it possible ?
    linux scp