0

I am trying to add an ssh public key to a bunch of servers authorized_keys file. My thought was to use pssh and a list of hosts. To test, I tried to pssh to one host:

pssh -i -H root@host echo mypublickeyasastring >> /root/.ssh/authorized_keys

When I run this, I get:

-bash: /root/.ssh/authorized_keys: Permission denied

If, from the same server I run pssh, I just ssh into the host ssh root@host, I get in okay and I can run echo mypublickeyasastring >> /root/.ssh/authorized_keys just fine.

I've been skimming the pssh man page but I can't seem to find anything. Am I missing something? Is there a better way to do this?

1
  • Have you though of using ssh-copy-id? Jan 7, 2015 at 21:13

1 Answer 1

2

The output redirection is happening on the local machine. You need to quote the command to protect the >>.

1
  • do you mean that I need to do pssh ... "echo mypublickeyasastring >> /root/.ssh/authorized_keys"
    – Mike
    Jan 9, 2015 at 14:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .