Ubuntu/Applications/PDSH
Applications | Java7 | Conky | Console Browsers | Fail2Ban | PDSH
Contents |
Overview
PDSH is currently (2015) one of the most popular solutions for Parallel Distributed Shell. It allows you to execute remote commands on a group or cluster of servers at the same time.
Step 1: Password-less SSH
PDSH is not coded to handle authentication prompts, so it requires that you setup pair of authentication keys rather than using /passwd.
Create the ssh public/private keys on the host (computer you will be connecting FROM).
~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/a/.ssh/id_rsa): [Enter key] Created directory '/home/a/.ssh'. Enter passphrase (empty for no passphrase): [Press enter key] Enter same passphrase again: [Press enter key] Your identification has been saved in /home/a/.ssh/id_rsa. Your public key has been saved in /home/a/.ssh/id_rsa.pub. The key fingerprint is: 3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Copy the public key to the remote-host (computer you will be connecting TO).
~$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host a@remote-host's password: Now try logging into the machine, with "ssh 'remote-host'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
You should now be able to ssh into the remote-host without a password:
~$ ssh remote-host Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2 [Note: SSH did not ask for password.] a@remote-host$ [Note: You are on remote-host here]
Step 2: Install PDSH on Host
Simple.
~$ sudo apt-get update && sudo apt-get install pdsh -y
Step 3: send a test command from the host to a few servers
PDSH allows you to create a HOSTLIST which you can use to easily call groups of computers. I'm not going to cover that, but you can find more information about it by visiting their wiki here.