Parallel ssh allows to execute commands on multiple hosts at the same time.
PSSH provides parallel versions of OpenSSH and related tools including:
pssh – run ssh in parallel on multiple remote hosts.
pscp – copy files in parallel to a number of hosts.
prsync –copy files in parallel to a number of hosts using the popular rsync.
pnuke – kills processes on multiple remote hosts in parallel.
pslurp – copy files in parallel from multiple remote hosts to a central host.
Pssh is written in python, so if python-pip is installed, simply run :
sudo pip install pssh
When connecting to remote hosts, the best and secure way is with ssh keys, but you have the ability to use a username/password.
To use a different username, we can use the -l
The host list:
The pssh tools are used with a list of hosts.
The hosts file contains one host name per line along with the IP address and port number that we need to connect to remote systems
=====================================================================
#######################
#example
#######################
192.168.0.101:22
#192.168.0.102 #ip-of-this-one-is-skipped it is a comment as in standard bash
192.168.0.125:1700
========================================================================
pssh -O StrictHostKeyChecking=no -h
-O StrictHostKeyChecking=no with the -O switch,we pass options of ssh to pssh. Here the host key checking is disabled.
This will disable the message about "authenticity of host can’t be established"._
ECDSA key fingerprint is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)?
-h
-t
-o
pscp -O StrictHostKeyChecking=no -h <hosts-file> -t <timeout> ~/localfile /tmp/remotefile
pslurp -O StrictHostKeyChecking=no -h <hosts-file> -t <timeout> /tmp/remotefile ~/localfile
pnuke -O StrictHostKeyChecking=no -h <hosts-file> -t 10 php-fpm
prsync -O StrictHostKeyChecking=no -h hosts-file -t 10 -a /home/sc/folder-to-send/ /tmp/folder-receive