Article

Getting PDSH and Wget to install SSH key

So, I wanted to spray an SSH public key on a bunch of hosts. Since I have PDSH installed, and I have the PDSH user key stored on those hosts, I used it to do what I needed. Below is a simple command that will grab a file, then appends it to an existing file.

The assumption is that you know what you're doing. With that in mind, I issue the command from the PDSH  as root, save the file to the ~/.ssh/ directory, then cat and append it to an existing authorized_keys2. Once that takes place, the file is removed from the destination. This beats having to do the same task repetitively or use a bash script. In other words, Parallel computing rules!

pdsh -l root -a 'wget http://[REMOTE URL]/[FILE] -O ~/.ssh/[FILE]
&& cat ~/.ssh/[FILE] && ~/.ssh/authorized_keys2 &&
rm -rfv ~/.ssh/[FILE]'

No comments yet.

Leave a Reply