If you manage numerous remote Linux machines in your data center, make it easier to run parallel commands to those servers with the help of PSSH.
How many times have you needed to run the same command on multiple remote Linux machines? When you're dealing with a data center filled with Linux machines, this can be an exercise in inefficiency. Fortunately this is Linux, so there's always a trick up the platform's sleeve.
Such is the case with parallel SSH (PSSH). I'm going to show you how to install and use this handy admin tool.
SEE: Hiring kit: Database administrator (TechRepublic Premium)
How to install PSSH
Since the tool is found in most standard repositories, it can be installed with a single command like:
sudo apt-get install pssh -y
Once installed, you need to create a host file. Issue the command:
In that new file, add IP addresses of each remote host, one per line. Once you've added all your hosts, save and close the file. Now, let's run the dh -f command on all of our remote machines.
To do this, issue the command:
parallel-ssh -A -i -h sshhosts df -h
The -A option will cause pssh to prompt you for your remote password. You'll want to make sure to have the same remote user (with the same password) on each machine.
Once authenticated, you'll see the output of the df -h command run on each remote host.
Note: This will assume that you have the same user on both local and remote machines. If that's not the case, you can always create your sshhosts file in the form of username@ipaddress.
And that's how you can run the same command, at the same time, on multiple remote Linux hosts. Give PSSH a try and see if it doesn't help make your Linux admin job a bit more efficient.
- How to become a database administrator: A cheat sheet (TechRepublic)
- 10 things companies are keeping in their own data centers (TechRepublic download)
- Snowflake is the Linux SSH GUI you didn't know you needed (TechRepublic)
- How to enable SSH login on macOS (TechRepublic)
- How to use per-host SSH configuration (TechRepublic)
- How to allow SSH connections from LAN and WAN on different ports (TechRepublic)
- Fortinet removes SSH and database backdoors from its SIEM product (ZDNet)
- Best cloud services for small businesses (CNET)
- DevOps: More must-read coverage (TechRepublic on Flipboard)