Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Coming from Windows administration, I want to dig deeper in Linux (Debian). One of my burning questions I could not answer searching the web (didn't find it) is: how can I achieve the so called "one-to-many" remoting like in PowerShell for Windows?

To break it down to the basics I would say:

My view on Linux:

  • I can ssh into a server and type my command
  • I get the result. For an environment of 10 servers I would have to write a (perl/python?) script that command for each of them?

My experience from Windows:

  1. I type my command and with "invoke-command" I can "send" this to a bunch of servers (maybe from a textfile) to execute simultaneously and get the result back (as an object for further work).

  2. I can even establish multiple sessions, the connection is held in the background, and selectively send commands to these sessions, and remote in and out like I need.

(I heard of chef, puppet, etc. Is this something like that?)

Update: I will go for cssh or pssh or dsh first and then take a look at Ansible. (Further, i hope to find out) how tmux does this parallel remoting like 'terminator' does. Thanks @jlliagre for pointing out the similar question with more ideas: How do I run the same linux command in more than one tab/shell simultaneously?

tmux: :setw synchronize-panes on

share|improve this question
parallel ssh may do it: serverfault.com/questions/2533/… – rogerdpack Mar 14 at 15:06
MobaXTerm supports "multi-execution" across many ssh sessions: mobaxterm.mobatek.net/features.html (scroll down). Also if your primary workstation environment is Windows it's also a pretty sweet tool for connecting to Linux boxes and much more. – Kev Mar 16 at 20:52
with tmux: :setw synchronize-panes on ( unix.stackexchange.com/a/124800/161003) – eli Mar 22 at 23:05
up vote 45 down vote accepted


  • Ansible is a devops tool that is a powerful replacement to PowerShell
  • RunDeck as a graphical interface is handy
  • Some people run RunDeck+Ansible together

For a beginner I would recommend clusterssh

To install clusterssh in Debian:

apt-get install clusterssh

Another clusterssh tutorial:

ClusterSSH is a Tk/Perl wrapper around standard Linux tools like XTerm and SSH. As such, it'll run on just about any POSIX-compliant OS where the libraries exist — I've run it on Linux, Solaris, and Mac OS X. It requires the Perl libraries Tk (perl-tk on Debian or Ubuntu) and X11::Protocol (libx11-protocol-perl on Debian or Ubuntu), in addition to xterm and OpenSSH.

As for a remote framework for multiple system administration, Ansible is a very interesting alternative to Puppet, as it is more lean, and it does not need dedicated remote agents as it works over SSH.

The Playbooks are more elaborate. However, to start using Ansible after a simple installation and setting up the client list text file, to run a command in all servers is as simple as doing:

ansible all -m command -a "uptime"

The output also is very nicely formatted and separated per rule/server, and while running it in the background can be redirected to a file and consulted later.

You can start with simple rules, and Ansible usage will get more interesting as you grow in Linux, and your infra-structure becomes larger. As such it will do so much more than PowerShell.

As an example, a very simple Playbook to upgrade Linux servers that I wrote.

- hosts: all
  become: yes
  gather_facts: False
   - name: updates a server
     apt: update_cache=yes
   - name: upgrade a server
     apt: upgrade=full

It also has many modules defines that let you easily write comprehensive policies.

Module Index - Ansible Documentation

It also has got an interesting official hub/"social" network of repositories to search for already made ansible policies. Ansible Galaxy

Ansible is also widely used, and you will find lots of projects in github, like this one from myself for FreeRadius setup.

While Ansible is a free open source framework, it also has a paid web panel interface, Ansible Tower although the licensing is rather expensive.

As a bonus, Ansible also is capable of administering Windows servers, though I have never used it for that. It is also capable of administering networking equipment (routers, switches, and firewall), which make it a very interesting solution as an automation turn key solution.

How to install Ansible

Yet again, for a remote framework easier to use, but not so potent as Ansible, I do recommend Rundeck. It is a very powerful multi-user/login graphical interface where you can automate much of your common day-to-day tasks, and even give watered down views to sysops or helpdesk people.

When running the commands, it also gives you windows with the output broken down by server/task. It can run multiple jobs in the background seamlessly, and allows you to see the report and output later on.

rundeck image

How to install RunDeck

Please note there are people running Ansible+RunDeck as a web interface; not all cases are appropriated for that.

It also goes without saying that using Ansible and/or RunDeck can be construed as a form or part of the infra-structure documentation, and over time allows to replicate and improve the actions/recipes/Playbooks.

Lastly, it you are talking about a central command server, I would create one just up for the task. Actually the technical term is a jump box. 'Jump boxes' improve security, if you set them up right.

share|improve this answer
Ansible is a great solution vs. some script or utility which merely broadcasts a command to multiple SSH servers. Ansible does that (and is a better fit for that purpose than Puppet or Chef), but also gives you the option of achieving your objective in a better way e.g. using a built in module to install something idempotently instead of just sending out the install command and hoping for the best. – JBentley Mar 16 at 7:28

If you want to do it interactively, you can use terminator which allows to broadcast a command to multiple terminals.

enter image description here

See: How do I run the same linux command in more than one tab/shell simultaneously?

share|improve this answer
thanks for the link!!! – eli Mar 14 at 11:30
Very annoying when you accidentally hit the shortcut for this feature... :) – pipe Mar 15 at 4:39

You can also use pssh (or parallel-ssh), which is an SSH client that connects to a list of hosts and executes the command on all hosts in parallel:

$ parallel-ssh -i -H "host1 host2" uname -a
[1] 11:37:12 [SUCCESS] host2
Linux host2 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[2] 11:37:12 [SUCCESS] host1
Linux host1 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
share|improve this answer

Perhaps you can achieve your goal with a simple zsh (bash) function. Let's say you have servers l61 l62 l63 and you often need to run a command on them:

function run_on_cluster()
    (for srv in l61 l62 l63;
        echo "ssh $srv $1";
    done) | parallel --gnu

So, in the command line:

$ run_on_cluster "uname -r"
share|improve this answer
I would recommend printing the name of the servers before their output. Running the script on parallel also brings other quirks, like fumbling the output of the script - extra measures have to be taken to preserve the activity of the output. Running each task in the foreground also offers the possibility of minimal input interaction. – Rui F Ribeiro Mar 14 at 9:15

If you're using KDE, here's another method.
- Open a Konsole window.
For each server you want to communicate with:
- open a tab
- establish ssh connection with the server
In the "Edit" menu, select "copy input" to "all tabs"

Every command you enter in that tab will be copied to all servers.
You can switch from tab to tab to look at the different results.

Note: my menu labels (in quotes) may be wrong since I do not use an english version of KDE

share|improve this answer

GNU parallel

It allows simple one-liners with saved settings, so you can create a profile, "prod', which will contain a server list and common switches. Then just add the command you want, and you are ready. It also can copy files to the server and automatically delete them at the end, and it's pretty convenient for even bigger scripts. Also it is very fast.

The only problem is that it has so many options ;) But the documentation also includes a lot of examples, so you can just look at them in the beginning.

share|improve this answer
Hi, Welcome to Linux and Linux. Someone already gave a script using gnu-parallel has an example. I advise you to give a look around, more elaborate answers are appreciated, and will give you more points. – Rui F Ribeiro Mar 15 at 8:27
@RuiFRibeiro sorry I did not notice, SO android app bugs with codeboxes and I could not see most of content (it generates blank white space). You mentioned gnu-parallel is fumbling output - it can write it in order but you have to tell it to do so :) – alkuzad Mar 15 at 9:04
Yes, I am not familiar with it, but already suspected so, hence mentioning the answer needs improvement. Thanks. Nothing prevents you writing a better answer around it, however for commenting, I do recommend commenting in that answer. – Rui F Ribeiro Mar 15 at 9:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.