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]
thanks!
--
bsdnexus cross-post
I'm not sure if you can do that directly, but if you put the command in a shell script and give it execute permissions, you should be able to add that to the sudoers file.
roddierod on bsdnexus gave a good solution, too. thanks.
i just wanted a quick one-liner for the cli.
he gave this, but it's a bit longer than my ideal solution:
sudo sh -c 'echo "ssh-rsa AAAAAA=" > /home/larz/.ssh/authorized_keys'
Ah, now I understood what you meant... Most times I just do "sudo -s" and get a shell :P