Server Fault is a question and answer site for system and network administrators. 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

*sudo cat idenityfile.rsa > authorized_keys*
-bash: authorized_keys: Permission denied

if I su - to the user then I can do this but why can I not do this with sudo from my user?

share|improve this question
Dupe of – mattdm Dec 17 '10 at 18:11
up vote 5 down vote accepted

The > redirection does not work like this with sudo.

You can use these alternative:

sudo sh -c 'cat idenityfile.rsa > authorized_keys'
share|improve this answer

It is because the redirect isn't "sudo"ed Try something like this instead:

sudo bash -c “cat idenityfile.rsa > authorized_keys”

share|improve this answer

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.