Parallel Shell
Used to remotely issue commands on multiple linux server.
Setup
Add the following to your .bashrc file
export PDSH_RCMD_TYPE=ssh
You should use ssh keys to authenticate. If you don't have one see SshKeys. We will use ssh-copy-id to copy the ssh key to the appropriate server
ssh-copy-id -i keyfile.pub username@target.server.com
Where you obviously need to change the file name and target.
If your key has a passphrase, you won't be able to use pdsh directly. First you will have to run the ssh-agent:
eval `ssh-agent -s` #starts the ssh agent if not started ssh-add -l #lists existing keys ssh-add ./.ssh/filename #adds the key and allows you to enter the passphrase
Now we need to create a "hosts" file to use with the system. For example:
root@server0.target.com root@server1.target.com root@server2.target.com
Now we can do things like
pdsh -w ^hosts apt update pdsh -w ^hosts apt -y upgrade
When you are done, you may want to delete your keys from the agent:
ssh-add -D
OR, just ending your session will end the ssh-agent and remove all keys.