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?
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”