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?


The > redirection does not work like this with sudo.

You can use these alternative:

sudo sh -c 'cat idenityfile.rsa > authorized_keys'

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

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

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.