Run commands on multiple servers

Run commands on multiple servers:

1.       Install pssh

#yum install python-pip

#pip install pssh


2.       Create host file pssh-hosts.txt

Add all hosts on which you need to run any command


3.       Run below command

#pssh -h pssh-host.txt -l root -A “passwd” -i “ping <ip-address>”


We assume you have multiple machines to manage but don’t have SSH-keys on them. It is still possible to use parallel-ssh  and without having to enter any passwords. “remotePasswdFile” contains your password to log in to the remote computer. parallel-ssh -I reads from stdin and -A asks for a password. -S reads the password from stdin here “remoteRootPasswordFile”.

#sshpass -f remotePasswordFile parallel-ssh -I -A -h hostlist “ls -l” < remoteRootPasswdFile 

To disable StrictHostKeyChecking

#sshpass -f remotePasswdFile parallel-ssh -x “-o StrictHostKeyChecking=no” -I -A -h hostlist “ls -lrt” < remoteRootPasswdFile