Sunday, July 1, 2012

OS X Fuse and SSHFS on a Mac

I do quite a bit of work where my files reside on a remote machine. Of course, I could log in to the remote machine and work on the files there, copy them to my local machine and then copy them back, use an editor that can read files from a remote machine, or many other methods. However, how about the cooler option of mounting the remote filesystem locally and then working on the files as if they were on my machine? Oh, and yes, since we want to be secure, we'll do all that over SSH.

To get this to work you'll need to install OS X Fuse. In case you care, OS X Fuse is an implementation of Fuse, which allows the creation of a filesystem in userspace. OS X Fuse, only installs the necessary library for the creation of that userspace filesystem. To be able to mount a remote directory on your local machine over SSH, you'll also need to intall the SSHFS libraries, which are conveniently located on the OS X Fuse page.

Once everything is installed, you can mount a remote file system using your terminal as follows:
local$ sshfs user@host:/path/to/dir  /local/path/to/mountpoint -ovolname=NameOfMountedVolume
This will take the directory found at "/path/to/dir" on the remote machine and mount it locally at "/local/path/to/mountpoint" and call the directory "NameOfMountedVolume". Now you can navigate to that directory using the terminal or Finder as if it were a local directory. To unmount it, simply run
local$ umount /local/path/to/mountpoint
Pretty cool, eh?

No comments:

Post a Comment