Cluster SSH with cSSHx

I am in the middle of building out a group of about 25 machines in a data center for my company. I hadn’t really dove into it on a micro level until a few days ago. I was moving around on individual machines that others were working on. When I had gotten to one of the “untouched” machines, I found that vim wasn’t installed. There was about 15 machines that were “untouched” and therefore were missing vim (along with other stuff). And seriously who wants to install a bunch of the same software on every machine after they’ve already been kickstarted?

So I could try to script it, but you really only get one shot when you script it. Then you have to deal with expect (or log in as root) and that’s a little bit of a pain too. So I decided to see what cluster SSH solutions are out there (since I haven’t needed them in a while). The kicker was that it had to work for Mac OS X. Typically anything that works on Linux has a variation on the Mac so I didn’t think that would be a problem.

First thing I found was a Perl application bundle that uses Tk to be a cluster SSH solution. Its available here. I had a little trouble getting some of the required CPAN modules installed and because I like instant gratification (plus I needed to get some stuff done), I had to pass.

The next thing I found was cSSHx and it’s just awesome. All you do is untar it, put it in your path and launch it as follows:

# csshx --login elubow 192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5

One of the nice things is that it equally sizes all the Terminal windows that it opens so that they share equal screen real estate. It provides a master typing bar to allow you to see what you’re typing in all sessions. And if you need to something to one particular machine, just click on that machine’s Terminal window and only that session will receive input (since it is just a Terminal session after all). Here is a screen shot of all of the 25 hosts open at once on my screen.

Screenshot of cSSHx

Screenshot of cSSHx with 20 sessions

This is an awesome piece of software. There are only 2 additional features that I think could make it better. I would like to be able to open up a range if the IPs are sequential. For instance 192.168.1.1/30 opens 192.168.1.1 and 192.168.1.2 (but on a much larger scale). This is easier than creating a list each time I want to go to just a subset of machines. I think it would also be great to be able to specify the password on the command line. I know security folks would go nuts over this, but in the long run, sometimes its just easier to put the password in the command line.

I want to leave you with 1 more thing. Although this is a nice tool, it can be even better with aliases. Add a bunch of groups to your .bashrc or you .bash_profile. Something along the lines of:

alias csshmail='csshx --login elubow 192.168.1.3 192.168.1.4 192.168.1.5'
alias csshdb='csshx --login elubow 192.168.1.35 192.168.1.34 192.168.1.37'
  • Pingback: Cluster SSH with cSSHx | Erics Tech Blog

  • Pingback: Tweets that mention Cluster SSH with cSSHx | Erics Tech Blog -- Topsy.com

  • Malcolm

    Does it not come with a .csshrc file to define your groups of clusters thereby avoiding the aliases?? It's linux counterpart cssh does…

  • http://eric.lubow.org Eric Lubow

    Yes, it does come with the ability to add cluster groups in the config. You can read the pod documentation on line (http://www.brock-family.org/gavin/macosx/csshX-…) that talks more about it. I generally prefer aliases since they are more easily portable, but with a complex configuration, a config file would be better.

  • http://www.brock-family.org/gavin/ Gavin Brock

    Malcolm, yes – compatibility with cssh was part of the original design – right down to the quirky .csshrc and /etc/clusters syntax.

  • http://www.brock-family.org/gavin/ Gavin Brock

    Thanks to Eric's great suggestions and patches, I just released version 0.64.

    http://gavcode.wordpress.com/2010/03/30/csshx-0

  • http://www.bzaugg.com/ Brian Zaugg

    Thanks, Eric! I'll have to check out cSSHx.
    I keep pdsh (http://sourceforge.net/projects/pdsh) in my toolbox for similar purposes.
    -Brian

  • skbenja

    Seems kind of slow. iTerm does more or less the same thing with 'send to all tabs.'

  • :(

    I would love to the same, but I can’t. When I type csshx –login “myusername” host1 host2 host3 … – I get one window (Master Window) – I don’t get that lovely set of tiled windows that the author gets. In addition, the Master Window presents me with some obscure options, none of which produce much results. The manual page isn’t very helpful either – I am running 10.6.4 so it is possible that it doesn’t run on my platform — are there any other options out there?