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?


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.

| improve this answer | |

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.