Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

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.

share|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.

share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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