C.W.K.
Stream
Lesson 04 of 14 · published

pssh — Purpose-Built Parallel SSH

~12 min · pssh, pscp, fleet

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

When shell loops aren't enough

pssh (Parallel SSH) is a dedicated tool for running commands on many hosts at once with proper output formatting, timeouts, and per-host status reporting. Where shell loops give you a wall of text, pssh gives you structured output — including which hosts succeeded and which failed.

The companion tools

pssh ships with siblings: pscp (parallel scp), prsync (parallel rsync), pslurp (gather files from many hosts). Same arguments, same host file, just different transports.

Code

pssh basics·bash
# Install
brew install pssh

# Run a command on every host in the file
pssh -h ~/.fleet/all.txt -i 'uptime'
# -h  hosts file
# -i  inline output (instead of per-host log files)

# With a timeout
pssh -h ~/.fleet/all.txt -t 30 -i 'df -h /'

# Concurrency cap
pssh -h ~/.fleet/all.txt -p 4 -i 'brew update'

# Push files in parallel
pscp -h ~/.fleet/all.txt local-script.sh /tmp/

# Run a local script on every host
prsync -h ~/.fleet/all.txt -a script.sh /tmp/
pssh -h ~/.fleet/all.txt -i 'bash /tmp/script.sh'
pssh vs the fleet() function·plaintext
Feature                | fleet() loop | pssh
-----------------------+--------------+-----------------
Parallel exec          | with & wait  | built-in
Clean per-host output  | yes (serial) | -i flag
Timeouts               | manual       | -t flag
File copy              | scp loop     | pscp
Exit-code summary      | DIY          | built-in

External links

Exercise

Install pssh (brew install pssh). Run pssh -h ~/.fleet/all.txt -i 'uptime' and observe the structured output. Then pssh -h ~/.fleet/all.txt -i -t 10 'df -h /' — note that any host taking longer than 10 seconds gets a clear timeout indicator. This is the production-shape of fleet command execution.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.