Mounting drives on OSX over ssh

My computer setup at work consists of a workstation running Linux, and a macbook. In a way to make things smoothly I wanted a way to automatically mount a drive from my Linux machine on my macbook so I can easily share files between the computers.

A really nice way of doing this is using ssfsh together with controlplane.

So this is a two-fold setup. Controlplane (which can be found here), can take a context, like getting a specific IP, and executing a program when this is true. sshfs, which works together with OSX Fuse, is used for mounting a drive via the ssh protocol, meaning it can be done from anywhere.

So they way I have this set up is that when I arrive at work, I’m plugging my macbook into the work network via ethernet cable. This gives me a static IP. Controlplane then recognises that I now have this IP (but the context could also be that you connect to a certain wifi for instance), and executes a small bash script, invoking sshfs. The script looks like this:

I now have my linux machines harddrives mounted on my macbook.

A second context rule in controlplane recognises when i do not have this specific IP, and unmounts the network drives via a second bash script, looking like this:

This allows for automatic mounting of the drives when I arrive at work. Of course, I can also mount the drive when I’m at some other network by manually invoking the bash scripts.