Support >
  About independent server >
  Pssh implements simultaneous commands on multiple remote linux servers
Pssh implements simultaneous commands on multiple remote linux servers
Time : 2025-01-13 13:33:14
Edit : Jtti

OpenSSH is one of the most commonly used tools on Linux servers. It provides secure remote connections to linux systems and has powerful functions. However, OpenSSH does not support executing the same command on multiple linux servers at once, so you can use parallel SSH or PSSH tools.

PSSH is a Python-based application that allows users to execute commands in parallel on multiple servers. PSSH tools include OpenSSH parallel versions and related senses such as pssh, pscp, prsync, pnuke, pslurp, etc. These tools are important for system administrators dealing with a large number of nodes in a network. Install the PSSH program using yum/dnf based on the pip package installed in RHEL distribution Linux:

yum install python-pip

perhaps

dnf install python-pip

After installing the pip tool, install the passh package with the pip command:

pip install pssh  

Install pssh with the pip command based on the debian distribution:

sudo apt install python-pip

sudo pip install pssh

When you use pssh, you create a host file that contains the number of hosts and the IP address and port number required to connect to a remote system using pssh. Lines in the host file take the following form, with blank lines and comments:

192.188.0.10:22

192.188.0.11:22

To run a single command on multiple linux servers, run echo on multiple linux host terminals as root:

pssh-h pssh-hosts -l root -A echo "Hello TecMint" and prompt for the root password:

Warning: do not enter your password if anyone else has superuser

privileges or access to your account.

Password: [1] 15:54:55 [SUCCESS] 192.188.0.10:22[2] 15:54:56 [SUCCESS] 192.188.0.11:22

The pssh-hosts file contains a list of the IP addresses and SSH port numbers of the remote Linux server where you want to execute the command.

To query the disk space usage of multiple linux servers:

pssh -h pssh-hosts -l root -A -i "df -hT"

Warning: do not enter your password if anyone else has superuser

privileges or access to your account.

Password: [1] 16:04:18 [SUCCESS] 192.188.0.10:22

Filesystem     Type   Size  Used Avail Use% Mounted on

/dev/sda3 ext4 38G 4.3G 32GB 12% /

tmpfs          tmpfs  499M     0  499M   0% /dev/shm

/dev/sda1      ext4   190M   25M  156M  14% /boot

[2] 16:04:18 [SUCCESS] 192.188.0.11:22

Filesystem              Type      Size  Used Avail Use% Mounted on

/ dev/mapper/centos - root XFS 30 G 34% 20 G / 9.8 G

devtmpfs                devtmpfs  488M     0  488M   0% /dev

tmpfs                   tmpfs     497M  148K  497M   1% /dev/shm

TMPFS TMPFS 497 M, 7.0 M 490 M 2% / run

tmpfs                   tmpfs     497M     0  497M   0% /sys/fs/cgroup

/dev/sda1               xfs       497M  166M  332M  34% /boot

To query the uptime of multiple linux servers:

pssh -h pssh-hosts -l root -A -i "uptime"

Warning: do not enter your password if anyone else has superuser

privileges or access to your account.

Password: [1] 16:09:03 [SUCCESS] 192.188.0.10:22

16:09:01 up 1:00, 2 users, load average: 0.07, 0.02, 0.00

[2] 16:09:03 [SUCCESS] 192.188.0.11:22

06:39:03 up 1:00, 2 users, load average: 0.00, 0.06, 0.09

See more uses of the passh manual entry page:

pssh --help

JTTI-Defl
JTTI-COCO
JTTI-Selina
JTTI-Ellis
JTTI-Eom