Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

*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
1  
Dupe of serverfault.com/questions/213347 –  mattdm Dec 17 '10 at 18:11
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

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.