Secure Shell is an indispensable resource for Linux users that tend to work with remote Linux servers, computers, or network devices. It’s fast, security-oriented, and allows users to do everything from sending commands to remote computers and servers, to opening programs over the internet.
For as useful as SSH is, it’s only possible to interact with one machine at a time. Limits like these won’t bother the average user who uses Secure Shell to remote in once in a while, but if you use the SSH protocol in your day to day to connect to many different Linux machines, it can be a bottleneck for productivity.
Over the years, the Linux community has come to terms with the limitations of the Secure Shell and has offered up ways to get around it. One such solution is Parallel SSH. It’s a program that lets users interact with multiple remote machines over Secure Shell at once.
The Parallel SSH tool makes use of OpenSSH on Linux, so you’ll need to have it set up on your system before attempting to follow along with this guide. Luckily, setting up an SSH server is very quick.
Refer to your Linux distribution’s wiki entry on SSH and learn how to get it going. If you have trouble getting it working, head over to our guide on how to set up SSH on Linux. It’s in-depth and covers everything you need to know!
Install Pssh on Linux
Before we get into how to use the Pssh tool, we need to go over how to install it. Getting the program working involves using various commands, so open up a terminal window and follow along with the instructions that match the operating system you use.
sudo apt install pssh
sudo apt-get install pssh
Pssh isn’t in Arch Linux’s package repositories. However, users can still easily install it, as there is a Pssh AUR package. To get the program working on your Arch PC, do the following:
sudo pacman -S base-devel git git clone https://aur.archlinux.org/python-pssh.git cd python-pssh makepkg -sri
sudo dnf install pssh -y
sudo zypper install pssh
Not every Linux OS has the Pssh tool in their software sources. If you’re running a distribution that doesn’t carry it, you will have to find an alternative way of installing it.
As of now, the best way to get Pssh on lesser-known Linux operating systems is via the Python package installation tool.
Note: be sure that you have python-pip (or) pip set up before attempting to use it to get Pssh.
sudo python-pip install pssh
sudo pip install pssh
Is Pip not working for you? Consider downloading the Pssh source code instead.
Set up Pssh
For the Parallel SSH tool to work, the user must set up a host file that outlines all of the remote computer addresses to use with the program. Launch a terminal and use the touch command to create a new Pssh host file.
Next, open up the host file with the Nano text editing tool. Using Nano, write out the addresses of every remote Linux machine running SSH you wish to interact with using Pssh. For best results, use the local or internet IP address, rather than the hostname.
When setting up the host file, keep in mind that you must add the username, along with the address. It should look like firstname.lastname@example.org.
After your host file is written out, save the edits by pressing Ctrl + O on the keyboard. Then, exit Nano with the Ctrl + X keyboard combination.
Sending commands with Pssh
Pssh is a wrapper for SSH that allows the user to interact with multiple machines at once. There’s no convoluted syntax to understand; if you already know how the Linux terminal works, it’ll make sense.
To send any command to your list of remote computers (at once) over Secure Shell via Pssh, do:
pssh -i -h ~/.pssh_hosts_files terminal command
Still not sure about how Pssh works? Try out some of the example commands below.
Need to check running processes on all of your Linux machines at once? Run top with Pssh.
pssh -i -h ~/.pssh_hosts_files top
Curious about how long all of your Linux computers have been running? Use the uptime command alongside the Pssh tool.
pssh -i -h ~/.pssh_hosts_files uptime
Hard drive space
Check how much hard drive space each remote Linux machine at the same time by using df with Pssh.
pssh -i -h ~/.pssh_hosts_files df -h
To check the system specs of all of the remote Linux computers on the host list, run inxi
pssh -i -h ~/.pssh_hosts_files inxi -F