Cluster SSH with cSSHx

By eric

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:

1
# 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:

1
2
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'

Follow My Travels

Buy My Book

Archives

  • 2017
  • 2014
  • 2013
  • 2012
  • 2011
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006

writing