PSSH (Parallel Secure Shell) is a tool that enables you to connect to multiple hosts via SSH simultaneously. It's useful for executing commands on multiple servers at once.
Install PSSH:
PSSH can be installed from the EPEL repository.
dnf --enablerepo=epel -y install pssh
Using PSSH with Key-Pair Authentication:
If you have set up SSH key-pair authentication on the target hosts without a passphrase, you can use PSSH as follows:
pssh -H "10.0.0.51 10.0.0.52" -i "hostname"
This command will execute hostname on both hosts, 10.0.0.51 and 10.0.0.52.
Reading Hosts from a File:
You can also specify hosts in a file and read from it.
# Create a file with host details
vi pssh_hosts.txt
# Add hosts to the file
cent@10.0.0.51
cent@10.0.0.52
# Execute a command using the hosts file
pssh -h pssh_hosts.txt -i "uptime"
Password Authentication with PSSH:
It's possible to connect using password authentication. Note that this requires the passwords on all hosts to be the same.
pssh -h pssh_hosts.txt -A -O PreferredAuthentications=password -i "uname -r"
Enter the password when prompted. This will execute uname -r on all hosts listed in pssh_hosts.txt.
pscp.pssh, prsync, pslurp, and pnuke. These tools can be used with similar syntax to pssh.Note: Replace 10.0.0.51, 10.0.0.52, cent@10.0.0.51, cent@10.0.0.52, and other placeholders with actual IP addresses, hostnames, and user names relevant to your setup. This document provides a guide for using PSSH for parallel execution of commands across multiple SSH servers.