Gavin’s Odd Bits of Code

2012-12-14 (Fri)

Permanent SSH tunnel to OS-X behind NAT

Filed under: Uncategorized — Gavin Brock @ 5:23 pm
Tags: , , ,

I sometimes have an OS-X machine behind NAT that I want to get back to when I’m on the internet.

One way to achieve this is to set up an ssh tunnel on a machine with a known IP.

I put this file in “/Library/LaunchDaemons/com.example.ssh-tunnel.plist”:

 

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN”
http://www.apple.com/DTDs/PropertyList-1.0.dtd”&gt;
<plist version=”1.0″>

<dict>

      <key>Disabled</key>
      <false/>

      <key>Label</key>
      <string>com.example.ssh-tunnel</string>

      <key>ProgramArguments</key>
      <array>
         <string>/usr/bin/ssh</string>
         <string>-R19922:localhost:22</string>
         <string>-Nn</string>
         <string>remote_user@tunnelhost.example.com</string>
      </array>

      <key>RunAtLoad</key>
      <true/>

      <key>KeepAlive</key>
      <dict>
         <key>NetworkState</key>
         <true/>
      </dict>

      <key>UserName</key>
      <string>root</string>

    </dict>
</plist>

In this example, tunnelhost.example.com is the globally known server, and remote_user is set up with ssh keys to allow passwordless access.

Now if I ssh to  tunnelhost.example.com and then ssh to localhost:9922, I get back to the NATed machine.

2010-05-02 (Sun)

csshX 0.72

Filed under: Software,Uncategorized — Gavin Brock @ 8:59 pm
Tags:

Another production release, like all future releases, this is a 10.5 or newer version.

Bug Fixes:

  • Dragging the bounds window between spaces now works (this is implemented in some embedded Ruby since there was no simple way to do it in Perl).
  • Fixed crash when opening windows to hosts that failed.
  • Reworked the coloring of windows in select/enable/disable mode. Those rare cases when the color was not reset should be fixed.

Features:

  • Much faster at opening windows. Some nasty AppleEvents code has helped grab control of the opened window faster.
  • –space command line option (and equivalent config command) to open csshX windows in a particular space.

I now have no bugs, and no user feature requests, so I’m getting bored. ;-)

Feedback welcome..

2010-03-30 (Tue)

csshx 0.64 released

Filed under: Uncategorized — Gavin Brock @ 10:57 pm
Tags:

I have finally cut a new csshX package – a lot of good stuff in this one:

New Features

  • Host and Subnet Ranges – see below
  • Ping test hosts before attempting to connect
  • Sort terminals by hostname
  • Zoom a single terminal to ‘full screen’ key binding
  • Added “enable next terminal” key binding
  • Added “send slaveid” (a guaranteed unique ID) to a terminal
  • Check for users odd shell settings in Terminal.app

Bug Fixes

  • Added the work-around for 10.6 64bit
  • Better window placement (less overlaps)
  • Use the system stty, not macports
  • Better handling of terminal color changes
  • Lots of doc typos and spelling fixes (and probably some new ones)

Get it here:

csshX-0.64.tgz

Hostname ranges

If you have a lot of similarly named hosts, or which to open all hosts in a subnet, hostname ranges will simplify things. Howerver this also allows to open crazy numbers of windows. To avoid this you can use the “ping_test” to make sure a host is up and ssh is working before opening a terminal window.
Subnets
You can specify subnets using two syntaxes:
192.168.1.0/28
192.168.1.0/255.255.255.240
This will also work with a hostname, assuming it resolves to a valid IP. If the IP address is not the network address, only that IP and IPs above that address will be used (e.g. 192.168.0.14/28 will only use 2 ip addresses).
Ranges
A range is declared in square brackets. Rules are separated by commas. Ranges use a minus-sign. Ranges can be numeric or alphabetic.
Some examples:
hostname[0-10]
192.168.0.[5-20]
host-[prod,dev][a-f]
192.168.[0,2-3].[1-2,3-5]
192.168.0.1:22[1-9]

csshX now on Twitter!

Follow brockgr on Twitter

2009-04-30 (Thu)

csshX 0.61 released

Filed under: Uncategorized — Gavin Brock @ 11:41 am
Tags:

New features:

  • A new “[s]end” mode that allows you to send host-names/connection strings to all windows
  • ssh-options can now be configured or set on the command line.
  • p in bounds mode shows you your current bounds, good for pasting into csshrc
  • Ctrl-a Ctrl-m to minimise all windows including master
  • Ctrl-a Ctrl-h to hide all windows and minimise master (my favourite :-))

Bug fixes:

  • Infinite loop on “enable mode” when some windows have closed.
  • Some document corrections

Available at: http://code.google.com/p/csshx/downloads/detail?name=csshX-0.61.tgz

Enjoy…

Create a free website or blog at WordPress.com.