Server Fault is a question and answer site for system and network administrators. 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

I have about a dozen Linux boxes that I occasionally need to run the same command(s) on. Is there an easier way (or automated way) to do this asides from logging on to each machine and running the command, one at a time? It's not the same commands all the time and it's not at a preset time so it's not something ideal for tools like cron.

share|improve this question
similar question… – hayalci Jun 10 '09 at 15:58

15 Answers 15

up vote 12 down vote accepted

Hm, maybe pconsole is the tool you want.

share|improve this answer
Wow, pconsole looks pretty cool! I installed it no problems and it looks to be great so far. Thanks! – Chris Bunch May 1 '09 at 16:02
It's one of my favorite tools too. :) np – Node May 1 '09 at 16:09

There's also ClusterSSH, which, well, does exactly what you think it does. Yay for descriptive naming!

share|improve this answer

You should check out Puppet here is a article on its setup and use

share|improve this answer
Hmm, Puppet looks pretty interesting. I'll take a look over it if pconsole starts failing me, since I already have it running and it's easier than learning Puppet's language. Thanks for the suggestion though! – Chris Bunch May 1 '09 at 16:04

You may try Capistrano. Originally it is a Rails deployment tool, but it grew to do many things with remote machines.

For a more complete aproach to administration of multiple machine you may want to try Chef.

share|improve this answer

Don't overlook pssh and dsh either; they're both much like gsh that @Philip Durbin mentioned.

share|improve this answer
There's also "pdssh" similar, apparently – rogerdpack Oct 1 '15 at 18:18

I guess I'll copy and paste my answer from Stack Overflow, which people seemed to like. . .

The issue of how to run commands on many servers at once came up on a Perl mailing list the other day and I'll give the same recommendation I gave there, which is to use gsh:

gsh is similar to the "for box in box1_name box2_name box3_name" solution already given but I find gsh to be more convenient. You set up a /etc/ghosts file containing your servers in groups such as web, db, RHEL4, x86_64, or whatever (man ghosts) then you use that group when you call gsh.

[pdurbin@beamish ~]$ gsh web "cat /etc/redhat-release; uname -r" Red Hat Enterprise Linux AS release 4 (Nahant Update 7) 2.6.9-78.0.1.ELsmp Red Hat Enterprise Linux AS release 4 (Nahant Update 7) 2.6.9-78.0.1.ELsmp Red Hat Enterprise Linux Server release 5.2 (Tikanga) 2.6.18-92.1.13.el5 Red Hat Enterprise Linux Server release 5.2 (Tikanga) 2.6.18-92.1.13.el5
[pdurbin@beamish ~]$

You can also combine or split ghost groups, using web+db or web-RHEL4, for example.

I'll also mention that while I have never used shmux, its website contains a list of software (including gsh) that lets you run commands on many servers at once. Capistrano has already been mentioned and (from what I understand) could be on that list as well.

share|improve this answer

Also take a look at func. Func lets you use a module architecture to control different aspects of a system, from dealing with packages, to running commands, etc. It works on a client/server module over SSL and has a fairly flexible authentication scheme as well.

share|improve this answer
Along with that, Func is being built by Red Hat, and is likely to see expanded use in future Fedora/RHEL products. This is definitely one to watch, as I expect it will become the de facto standard solution for this type of problem. – Christopher Cashell Jun 12 '09 at 19:13

If you are already a tmux user, you might enjoy tmux-ssh. You give it a list of server names and it opens a new tmux window with an SSH session open to each server in its own pane. All keystrokes are copied to each window. Depending on the number of hosts the output can be hard to read.

share|improve this answer
One liner links aren't necessarily useful. Please be descriptive. Why do you recommend this tool? – Deer Hunter Jul 7 '15 at 6:29
Thanks, added some more context. – appleshampoo Oct 19 '15 at 23:06

If you are on a KDE desktop, konsole has the "Send Input to all sessions" option. It applies to all the sessions opened in the same konsole window.

share|improve this answer

You could also try ssh [user@]hostname [command] and then loop through the host names.

share|improve this answer
This doesn't really satisfy the "at once" part (it's serialized, not in parallel), but as that doesn't seem to be a requirement from the question's body this may also be a decent solution. – voretaq7 Dec 19 '11 at 22:00

Other tools are:

RunDeck could also be descriped as the lightweight ControlTier.

These tools not only give you a cluster shell, but also a web frontend and you can save your jobs for future use.

share|improve this answer

I've used ClusterSSH and it works. However, beyond a certain number of terminals, it doesn't scale well.

I'm surprised no one has mentiond xargs. Xargs is perfect for most things. In fact, I've gotten so comfortable with it that I never use clusterssh anymore.


echo -n host1 host2 host3 host4|xargs -d" " -n1 -P30 -I+ ssh + "sudo service apache2 restart"

(Restart apache on all web hosts.)

share|improve this answer

Ansible has ability to do ad hoc commands and is also expandable to do full config management. The ability to match based on groups is excellent.

share|improve this answer
ansible works well with hundreds of machines at once or you can limit it to n machines at a time – chicks Oct 19 '15 at 23:41

You can also try Cluster SSH (cssh). I haven't used it, but there's an article on called "Manage Multiple Servers Efficiently" that talks about it.

share|improve this answer

Use dish, simple and very powerful ! This script changed my life :) One script to rule them all !

The diligence shell 'dish' executes commands via ssh/rsh/telnet/mysql simultaneously on several systems. Changing password, updating configuration, copying files, checking status, etc. on hundreds of nodes is made then simple. Dish is similar to the IBM's 'dsh' (distributed shell) but furthermore allows remote execution of commands requiring authentication. Compared to other open source packages which include a distributed shell (or similar tools) like ClusterIt, dancer's shell, parallel distributed shell, or C3, dish is a slim and easy to use remote-shell wrapper for cases where a flexible solution is needed. You can browse the dish's manual page on-line here.

share|improve this answer

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.