8

My scp doesn't respect umask setting of the user it's sending files to. Is there a setting somewhere or should I use a different solution?

2 Answers 2

7

The umask, in the way you mean it, is a property of the login shell. It is set in .profile or one of its relatives. Since scp doesn't log in interactively, it doesn't run any of these scripts, so it doesn't get the umask setting you've defined there.

The closest thing I can think of to what you want is to set the permissions appropriately on the file locally, then use the -p option to scp to preserve the file modes.

You might also find rsync helpful. If you use its -a option, it will preserve almost all attributes of a file when copying, including permissions and modes.

2

According to this answer over on ServerFault it looks like the best way to make this happen is to introduce pam_umask into the target systems authentication sequence.

2
  • I want it to be set only for a specific user on the target system.
    – tshepang
    Jul 19, 2011 at 15:03
  • or adjust /etc/login.defs which pam_umask uses
    – fche
    Jun 11, 2020 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .