Not long ago, crazy-nerd Amit Singh posted the fruits of his (and others) labour to get FUSE (File System In Userspace) working under OS X. The results are nice, and work more-or-less out of the box.
What’s neat about SSHFS is that I can now, for example, mount the hard drives of the web servers I work on as normal directories on my computer, eliminating the need for dealing with an FTP client, and allowing me to open websites are projects using my text-editor of choice, TextMate.
However, all is not well if your server layout uses a lot of symlinks, as mine does. The sshfs.app that comes with the MacFUSE SSHFS package doesn’t use the follow_symlinks option by default, and there’s no preference to turn it on. Luckily for us, sshfs.app comes with the command-line version of SSHFS built-in. All it takes is a couple terminal commands, and you’ll be opening Transmit with less frequency in no time.
How To Do This Thing I Mentioned: The Pre-Requesiting
The first thing we’ll need to do, obviously, is to download and install both MacFUSE and the SSHFS packages from the project’s Google Code site. After installing MacFUSE, you’ll have to reboot your machine, due to the fact that FUSE is actually a kernel extension, that need to load when OS X first starts up. While you’re doing that, I’m going to go crack open a Red Bull. We’ll see who finishes first.
Step 2: Termina, Round 1: The symlink
The next step is the meat of our SSHFS implementation, and you’ll need the use of our friend, the Terminal. He lives in /Applications/Utilities/ and likes long walks on the beach, shell scripts, and perl. Luckily for us, we won’t need any of those things. Just a couple of simple commands.
As stated above, the SSFHS package provided by Google Code gives us just what we need, but it’s kind of hidden. After you’ve downloaded the package, and dragged sshfs.app into your /Applications folder, pop open your Terminal and put in the following code:
sudo ln -s /Applications/sshfs.app/Contents/Resources/sshfs-static /usr/local/bin/sshfs
The above code creates a symlink (symbolic link) to the command-line version of the SSHFS application, which exists inside the app we downloaded from Google Code. We use sudo here, because we need temporary Root access, to modify the /usr/local/bin directory. Putting a link to the application inside /usr/local/bin is entirely optional- it just makes things simpler. Instead of typing ‘/Applications/sshfs.app/Contents/Resources/sshfs-static’ every time we want to use the app, now we can just type ‘sshfs’, instead.
Step 3: The Finishing Of the Thing We Started A Minute Ago
The final step is to actually USE the sshfs tool, now that we’re all set up. sshfs’ invocation is pretty simple, and if you want more info, you can check out the documentation for yourself. For the purposes of this howto, though, I’m just going to show you how I do it. I do it like this:
sshfs user:remote.server:/remote/path /your/path/here -oreconnect,ping_diskarb,follow_symlinks,volname=VOLUME_NAME
This invokes our new friend sshfs, tells it we want to log onto a server, located at the address remote.server, directory /remote/path, with the username user. We also want to mount the directory on our machine in the directory /your/path/here (personally, I use /Volumes/servername), and with a bunch of options at the end. You don’t really need to know about those, I promise. The main one we’re interested in is follow_symlinks, which was the whole point of my taking this journey down tutorial lane.
If you’re successful, the server share should mount onto your desktop, and you can interact with it just like it’s a normal part of your own hard drive, without needing to use an FTP client to transfer files, browse directories, delete items, or any other mundane or advanced task. Enjoy.
This article was originally posted to murderthoughts.com