Topic: sudo question

is it possible to run commands like this with sudo?

echo "ssh-rsa AAAAAAAA=" > /home/larz/.ssh/authorized_keys

the part of the command that needs sudo isn't the echo, but writing it to the file in another user's directory. as a result, this doesn't work:

% sudo echo "ssh-rsa AAAAAAAA=" > /home/larz/.ssh/authorized_keys
[zsh: permission denied: /home/larz/.ssh/authorized_keys]



ttf cross-post

Last edited by lucas (2009-08-12 07:24:26)

Re: sudo question

You're using zsh so I'm not sure of the format, but this worked for with with plain old sh:

sudo sh -c 'echo "ssh-rsa AAAAAA=" > /home/larz/.ssh/authorized_keys'

Last edited by RoddieRod (2009-08-12 16:23:24)

"An educator never says what he himself thinks, but only that which he thinks it is good for those whom he is educating to hear."

Re: sudo question

yeah already noticed that it will run echo with sudo and > with user account.

Nice idea RoddieRod

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

Re: sudo question

only eight additional keystrokes smile

Re: sudo question

Ok, time to unsubscribe because of the low SNR (spam).