5

I'm just wondering if there is any fellow sysadmin with the need to execute one command on multiple servers. If so, what technique are you using?

I have grown tired to ssh-ing to 3-5 servers and executing the same thing over and over again, so I'm thinking to make my life easier.
Also, I think I should create keys so I don't have to enter passwords anymore (though I'm using root). After 2 years of doing this, I kind of developed a laziness.

I googled it up, I know about cssh, pssh, tentakel (this one seems cool), and the more pro-genre - Puppet (of which I just heard of, didn't invest the time to read the docs).

BTW, I'm using XP+putty, so if there is any putty-cool-thingy available, that's welcome too. If not, I can always ssh to one server and from there start my rest-of-the-servers-conquest :) *evil*

Hit me up. Thanks.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
w00t
  • 1,164
  • 3
  • 19
  • 35
  • 1
    Ever heard of a batch file? – John Gardeniers May 20 '10 at 13:51
  • that's not quite a great idea. – w00t May 21 '10 at 07:01
  • What are you executing? How do you know it worked or had the expected result on all the servers without actually going through them one-by-one or introducing an actual management system? Things sometimes sound a bit complex for a reason (though more often for no good reason) ^^ – Oskar Duveborn Aug 11 '10 at 14:59

6 Answers6

8

Look at:
clusterssh

Casual Coder
  • 1,216
  • 1
  • 11
  • 12
  • I'm on xp so I can't use clusterssh – w00t May 21 '10 at 08:16
  • I suppose it can be done via Cygwin. – Casual Coder May 21 '10 at 09:02
  • i just searched it and it doesn't seem to be a way. i found puttycm which is for $indows, but it needs many improvements. clusterssh would had been great, indeed. – w00t May 21 '10 at 13:48
  • from http://sourceforge.net/apps/mediawiki/clusterssh/index.php?title=FAQ#Working_Platforms : "It should work on any POSIX compliant UNIX style OS, i.e. cygwin" also google search gives -> http://jon.limedaley.com/plog/post/installing-clusterssh-on-cygwin – Casual Coder May 21 '10 at 16:53
  • I'm glad to hear that. – Casual Coder May 25 '10 at 18:20
  • I've had troubles installing clusterssh on Windows using Cygwin, and the Perl that was available to Cygwin. – FilBot3 Nov 10 '14 at 20:21
2

If you're a Ruby person then Capistrano is worth considering. If you're keen on the idea of Puppet then cfengine and bcfg2 are also worth taking a look at.

I'm really liking Capistrano for regular tasks, though I'm not sure I'm using it very well and I'd probably benefit from some training. For more one-off tasks I'd recommend clusterssh.

WheresAlice
  • 5,530
  • 2
  • 24
  • 20
2

Have a look at:

http://www.millardsoftware.com/puttycs

It is a wrapper around PuTTy that performs a similar function to Cluster SSH.

Dave C
  • 21
  • 1
  • I'm using puttycs myself. To help in opening multiple windows at once, I also found http://www.ntsend.freeserve.co.uk/puttymenu.html – Alister Bulman Aug 04 '11 at 09:55
2

dssh or pssh may provide you with what you need.

gWaldo
  • 11,957
  • 8
  • 42
  • 69
0

If you have ssh keys setup and installed and want something simple:

#!/bin/bash
SRVLST="server1 server2"

for SRV in $SRVLST
do
    echo Logging into root\@$SRV
    ssh root@$SRV "$1"
done

However if you really want to controll things properly you should look at a utility such as Puppet

Antitribu
  • 1,719
  • 3
  • 23
  • 37
  • 1
    cssh and dsh do this better – ptman May 20 '10 at 09:03
  • there are likely many many better ways to do this; it's a simple option nothing more. The preference would be to implement a system to actually control them along the lines of Puppet as mentioned in the question. – Antitribu May 20 '10 at 09:06
  • Actually I do have a script in bash that does this for my apache-cluster: read answ com=\`ssh web2 "$answ"` echo "$com" but I want to try something more efficient. – w00t May 20 '10 at 09:52
0

If you need just to execute the same commands on a set of servers, then I would suggest clusterssh: I use it routinely and it works very well.

  • don't i need x-server for cluster ssh? – w00t May 21 '10 at 08:20
  • Yes, clusterssh needs an X server, I use it on Windows boxes with Cygwin's X-Server. – Sebastiano Pilla May 21 '10 at 17:59
  • 1
    @sebastianopilla how many servers do you open in one session? do you have more than 10? I have two LCDs but I cannot resize the cygwin window, so I'm basically stuck to one LCD's size (17", 1280x1024) and if I want to open more sessions I cannot cram them up in there. Can you resize? – w00t Jun 18 '10 at 12:42
  • @woot, the maximum I've done is 6, on my setup (26" main screen, 17" secondary screen) it was quite usable. I've just tried it again, and I was able to freely resize all of windows; if it doesn't work for you then there might be some issue with your Cygwin/X setup, or with clusterssh's .csshrc file. – Sebastiano Pilla Jun 20 '10 at 20:35
  • @sebastianopilla I was referring to the cygwin window itself, not the other windows contained in it. So the one that it is displayed in your Taskbar, can you resize that one? – w00t Jun 22 '10 at 09:03
  • @woot, I have one Cygwin/X window that I can resize freely where I type the clusterssh command: this command then opens one independent window for each terminal, which all are freely resizable again. Try lauching Cygwin/X with the "-multiwindow" parameter and see if it improves the situation. – Sebastiano Pilla Jun 23 '10 at 09:11