PSSH – Parallel SSH Tools

Sponsored Link
PSSH provides parallel versions of OpenSSH and related tools. Included are pssh, pscp, prsync, pnuke, and pslurp. The project includes psshlib which can be used within custom applications.PSSH is supported on Python 2.4 and greater (including Python 3.1 and greater).

Install pssh on ubuntu

Open the terminal and run the following commands

sudo apt-get install python-pip

sudo pip install pssh

Using PSSH

PSSH Syntax

pssh [-vAiIP] [-h hosts_file] [-H [user@]host[:port]] [-l user] [-p par] [-o outdir] [-e errdir] [-t timeout] [-O options] [-x args] [-X arg] command

PSSH Examples

Connect to host1 and host2, and print "hello, world" from each

pssh -i -H "host1 host2" echo "hello, world"

Print "hello, world" from each host specified in the file hosts.txt

pssh -i -h hosts.txt echo "hello, world"

Run a command as root with a prompt for the root password

pssh -i -h hosts.txt -A -l root echo hi

Run a long command without timing out

pssh -i -h hosts.txt -t 0 sleep 10000

If the file hosts.txt has a large number of entries, say 100, then the parallelism option may also be set to 100 to ensure that the commands are run concurrently

pssh -i -h hosts.txt -p 100 -t 0 sleep 10000

Run a command without checking or saving host keys

pssh -i -H host1 -H host2 -x "-O StrictHostKeyChecking=no -O UserKnownHostsFile=/dev/null -O GlobalKnownHostsFile=/dev/null" echo hi

Print the node number for each connection (this will print 0, 1, and 2)

pssh -i -H host1 -H host1 -H host2 ‘echo $PSSH_NODENUM'

The above examples from PSSH man page


If you have a set of hosts that you connect to frequently with specific options, it may be helpful to create an alias such as:

alias pssh_servers="pssh -h /path/to/server_list.txt -l root -A"

The ssh_config file can include an arbitrary number of Host sections. Each host entry specifies ssh options which apply only to the given host. Host definitions can even behave like aliases if the HostName option is included. This ssh feature, in combination with pssh host files, provides a tremendous amount of flexibility.

Sponsored Link

Related posts

One thought on “PSSH – Parallel SSH Tools

Leave a comment

Your email address will not be published. Required fields are marked *