SCP and UMASK Linux Centos

4.5k Views Asked by At

I need to control the transferring of files on my server. Some files are sent through scp to my server and I want such a files to have a specific set of permissions let's say 770. I tried pam_umask.so in /etc/pam.d/login and setting umask in /etc/profile but it seems to not work.

Which is the best way on Linux to force an umask for files transferred via scp?

Regards, Andrea

1

There are 1 best solutions below

5
On BEST ANSWER

AFAIK, scp does not initialize a shell, thus don't source any file such as .profile, .bashrc, /etc/profile.

So the only way of doing this, as commented by Stefan Ferstl, seems to use the pam module pam_umask.so.

The file /etc/pam.d/sshd is probably the best place to do it, if you want to limit this behavior to ssh sessions :

session optional pam_umask.so umask=0007