0

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?

Joey BagODonuts
  • 1,635
  • 2
  • 16
  • 16

2 Answers2

6

The > redirection does not work like this with sudo.

You can use these alternative:

sudo sh -c 'cat idenityfile.rsa > authorized_keys'
wag
  • 416
  • 3
  • 6
0

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

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

Michael Jensen
  • 376
  • 2
  • 1