Master Parallel SSH: Install, Use, and Extend the pssh Tool Suite
This guide introduces parallel-ssh, a Python-based asynchronous SSH library for small‑scale automation, covering its history, Python‑3 support, installation methods across platforms, command‑line utilities (pssh, pscp, prsync, pslurp, pnuke), usage examples, and resource considerations.
parallel-ssh is an asynchronous, parallel SSH library designed for small‑scale automation, providing tools such as pssh, pscp, prsync, pslurp, and pnuke. Originally hosted on Google Code and maintained by Brent N. Chun, the project was handed to Andrew McNabb in 2009 and later archived when Google Code shut down.
Earlier releases did not support Python 3, but a GitHub fork adds Python 3 compatibility, and an organization has also attempted maintenance, though it has not been updated recently. Relevant repositories include:
https://github.com/lilydjwg/pssh
https://github.com/ParallelSSH/parallel-ssh
Scalability : Can manage hundreds to thousands of hosts.
Ease of use : Only two lines of code are needed to run commands on any number of machines.
Performance : Claimed to be the fastest available Python SSH library.
Resource efficiency : Consumes less resources than alternative Python SSH libraries.
# Mac installation
$ brew install pssh
# CentOS installation
$ yum install pssh
# Ubuntu installation
$ apt install pssh
# Pip installation
$ pip install pssh
# Source compilation (2.3.1)
$ tar zxvf pssh-2.3.1.tar.gz
$ cd pssh-2.3.1
$ python setup.py installThe installed binaries include:
# List installed tools
$ ls -lh /usr/local/Cellar/pssh/2.3.1_1/bin/
pnuke -> ../libexec/bin/pnuke
prsync -> ../libexec/bin/prsync
pscp -> ../libexec/bin/pscp
pslurp -> ../libexec/bin/pslurp
pssh -> ../libexec/bin/pssh
pssh-askpass -> ../libexec/bin/pssh-askpasspssh
Runs commands in parallel on multiple hosts via SSH.
# Usage: pssh [OPTIONS] command ...
# Run on two hosts and print output
pssh -i -H "host1 host2" hostname -i
# Save output to separate files
pssh -H host1 -H host2 -o /path/to/output_dir hostname -i
# Use a hosts file
pssh -i -h /path/to/hosts_file hostname -i
# Run as root (prompt for password)
pssh -i -h /path/to/hosts_file -A -l root_user hostname -i
# Pass extra SSH options
pssh -i -h /path/to/hosts_file -x "-O VisualHostKey=yes" hostname -i
# Limit parallel connections to 10
pssh -i -h /path/to/hosts_file -p 10 'cd dir; ./script.sh; exit'pscp
Copies files in parallel to multiple hosts via SSH.
# Usage: pscp [OPTIONS] local remote
# Copy local file to remote machines
pscp -h hosts.txt -l root foo.txt /home/irb2/foo.txtprsync
Efficiently copies files in parallel to multiple hosts using rsync.
# Usage: prsync [OPTIONS] local remote
prsync -r -h hosts.txt -l root foo /home/irb2/foopslurp
Copies files from multiple remote hosts to a central host via SSH.
# Usage: pslurp [OPTIONS] remote local
pslurp -h hosts.txt -l root -L /tmp/outdir /home/irb2/foo.txt foo.txtpnuke
Kills processes matching a pattern on multiple remote hosts via SSH.
# Usage: pnuke [OPTIONS] pattern
pnuke -h hosts.txt -l root javaSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
