Ubuntu/Applications/PDSH

From r00tedvw.com wiki
Jump to: navigation, search

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: [Enter 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.
Send a test and see what OS each computer is running

~$ pdsh -w ssh:username@host1,host2,host3 'grep . /proc/sys/kernel/ostype'

If all the hostnames are similar except for the last digits, you can also do it this way:

~$ pdsh -w ssh:username@host[1-3] 'grep . /proc/sys/kernel/ostype'
Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Open Source Products
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
MagicMirror
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
Politics
Volkswagen
Covid
NCDMV
Toolbox