Gavin’s Odd Bits of Code

2009-02-11 (Wed)

csshX – Cluster SSH tool using MacOS-X Terminal.app

Filed under: Software — Gavin Brock @ 9:54 pm
Tags:

One of the all time great sysadmin tools is Cluster SSH. It allows you to open up ssh sessions on multiple machines and send commands to them all through a common master window. It’s a perl script that uses xTerms and Tk.

My problem was that OS-X has a bit half-hearted X11 support and I always wanted a version that used Terminal.app. Finally after messing with some Applescript the other day, I realised it is possible to do.

So I have created csshX – my OS-X homage to cssh.

csshX is pure Perl (with calls to AppleScript) and should run on any 10.4 or 10.5 machine.

One known issue is that if you change focus, while csshX is opening many windows, it may capture the wrong terminal window. This is because there seems to be no good way to capture a handle to a Terminal window while you are opening it (I have to grab a handle to the front-most window after it has opened).

Let me know if you find csshX usefull, or you have any good ideas about how I could improve it.

Advertisements

20 Comments »

  1. i was just thinking about this!

    thx.

    Comment by snovotny — 2009-03-02 (Mon) @ 12:09 pm | Reply

  2. Thanks for this, perfect timing! I’d like to file a minor bug report though ;) There is a typo in the title of the master Terminal window, it reads “connetions”, not “connections”

    Comment by 1esproc — 2009-03-04 (Wed) @ 3:42 am | Reply

  3. 1esproc – thanks for that – I fixed it in the code base (which is moving to Google Code – http://code.google.com/p/csshx/)

    Comment by brockgr — 2009-03-04 (Wed) @ 11:25 am | Reply

  4. […] During a reading session online, I came across the following post on cluster SSH. Very nice when connecting to multiple machines to do common work. I can image the […]

    Pingback by cluster SSH « Ramblings of steinne — 2009-04-09 (Thu) @ 3:01 am | Reply

  5. I just discovered this tool and it’s saved my life for a task I had this week. Thanks!

    I do have one, rather esoteric, feature request. It would be nice to be able to identify sets of machines within the open windows and toggle the enabled-ness of a whole set at a time.

    Comment by Boyd Adamson — 2009-04-09 (Thu) @ 5:30 pm | Reply

  6. Boyd, Glad it’s come in handy.

    Regarding the feature, I sort of see where you are coming from, but how would you want select a “set” of machines. I know their hostnames when you opened them so could use that – some kind of pattern match?

    Feel free to open a feature request at: http://code.google.com/p/csshx/issues/list (so I don’t forget about it)…

    Comment by brockgr — 2009-04-09 (Thu) @ 5:39 pm | Reply

  7. Great Tool!
    Any options to change the ssh port?

    Comment by Ido — 2009-06-24 (Wed) @ 5:48 am | Reply

    • Ido..

      Firstly, make sure you have the latest version http://csshx.googlecode.com/files/csshX-0.63.tgz (0.62 and earlier had some bug with ports).

      You should be able to just call:
      csshX hostname:1234

      Another option is to code the ports in your .ssh/config:
      Host hostname
      Port 1234

      The latter has the advantage of working in all ssh based programs, eg csshX, scp, sftp etc.

      Hope this helps….

      Comment by brockgr — 2009-06-24 (Wed) @ 7:28 am | Reply

  8. yep – both works.
    Thanks!!

    Comment by Ido — 2009-06-24 (Wed) @ 7:34 am | Reply

  9. Thanks!

    Comment by m — 2009-09-07 (Mon) @ 3:55 pm | Reply

  10. Hi Gavin

    I’ve used cssh for years on Linux and I already like your version better! For some reason (the terminal, or TCL/TK, I don’t know) some key combinations never worked right for me, but they seem to work OK with csshX.

    Just one issue: I have the dock on the left side of the screen and the windows get below it. Is there a way to make all the term windows rearrange without getting below the dock? If not dynamically, maybe setting a margin on the config file.

    Thanks!

    Comment by Bisente — 2009-11-24 (Tue) @ 10:20 pm | Reply

  11. […] me he puesto a buscar equivalentes para MacOS X, y mira tu por dónde un tío se ha currado el csshX, una re-implementación de la misma idea, esta vez en perl en lugar de TCL/TK y con el Terminal.app […]

    Pingback by csshX « Jompeich d'er Bisente — 2009-11-25 (Wed) @ 5:30 am | Reply

  12. Thanks so much!

    I need to go through a middle host and an alternate port to get to my ultimate destinations. This is how I got it to work:

    csshX –ssh_args “-p33 username@www.domain.com -t ssh” host1 host2 host3 host4

    Comment by Kelly John Carney — 2009-12-06 (Sun) @ 2:24 am | Reply

  13. My osX is running 64bit. Need a way to specify running the script 32bit perl.

    Comment by John — 2010-10-30 (Sat) @ 11:03 pm | Reply

  14. I love the idea of this and it would probably save us a lot of time, but I feel like there’s a document missing — and the man page isn’t very helpful. More documentation would be wonderful.

    Comment by mzmallon — 2010-11-10 (Wed) @ 5:58 am | Reply

  15. If you get an error about 64-bit architecture from Perl, add following line to your ~/.bash_profile:
    export VERSIONER_PERL_PREFER_32_BIT=yes

    I noticed one thing – arrows don’t work in vim (I use ‘hjkl’, though.).

    Comment by ahes — 2011-04-12 (Tue) @ 8:38 pm | Reply

  16. Thank you, this was one of the things preventing me from using osx as a desktop and we are a very apple heavy shop.

    Comment by Dan — 2011-11-02 (Wed) @ 7:20 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: