It’s been a while since I posted, mostly because I have been swamped at work. But I ran across a sweet tip I want to document. Macosxhints ran a brief article called Mount a gateway-accessed server directly using MacFUSE. That sounded really handy to me, but I had to modify their instructions to get them to work.

Here’s the use case. I want to use sshfs to mount a remote file system. The remote machine is called tangerine, but there is a catch. Tangerine is not directly accessible. I have to go through another machine, one called fennel. The client machine for all of this is my mac, called willow, but its name does not matter here.

I have sshfs.app installed in the Applications directory of my mac, but this is going to require some command line work. The first step is to create a symbolic link to sshfs. This is done exactly as described by Macosxhints:

sudo ln -s /Applications/sshfs.app/Contents/Resources/sshfs-static /usr/bin/sshfs

Next step: I created a shell script in my home directory on the mac. I put the script in /Users/joe/bin/fennel-ssh. Here it is:

#!/bin/sh
ssh -i /Users/joe/.ssh/id_rsa drc@99.999.999.99 ssh $@

Some explanations. /Users/joe/.ssh/id_rsa is my private RSA key; I previously set things up so that this key authenticates me on both fennel and tangerine. 99.999.999.99 is the (obfuscated) ip address of the gateway machine, fennel. My userid on fennel is drc. Note that the Macosxhints version of this script did not pass in the RSA key, nor did it specify a user on the remote machine.

Here is how the script is used:

sshfs -o ssh_command=”/Users/joe/bin/fennel-ssh” drc@tangerine:/home/drc /Users/joe/remote -oreconnect,volname=tangerine

The command above mounted my tangerine home directory, /home/drc, on my mac desktop, with a label of ‘tangerine’. /Users/joe/remote is an empty directory used as a mount point. I’ll write another script to parameterize and encapsulate the long command above when I get a chance. Enjoy.