Setting up MacFUSE and sshfs (and more)

Background

The FUSE (Filesystem in USErspace) system is a method to allow secure mounting of remote disks and filesystems without requiring root privileges on either end. While it began as a kernel extension for Linux, it is now available for OS X as well. (See the Fuse4X/OSXFUSE page for more information.)

Of particular interest to us is the Secure Shell Filesystem, sshfs.

SSHFS allows you to mount a remote disk from any computer for which you otherwise have ssh shell access. (SSHFS operates as a compiled shell around SFTP.) At that point, you have local Mac access to the files on the remote server, with the same (read-write-execute) permissions you would have if you had ssh'ed to start a remote shell on that computer. However, you can bring the power of your Mac to bear on those files, including editing them with local applications (TextWrangler, TeXShop, Photoshop), inspecting them (the Finder, QuickLook), and more.

Furthermore, SSHFS can do 'tricks' that NFS (Network File System) cannot, such as (a) mounting a server disk from a wireless computer and (b) not requiring root access on either the UNIX server or the local Mac.

Installation

While there are GUI installers available for this, it is very easy to get this running via MacPorts or Fink.

If you are running 10.6 installed by the ASD system team, then you probably have Fink (unless you installed MacPorts on your own). For 10.8 systems, ASD would have provided you with MacPorts, while the 10.7 systems are a mixture (look for /sw or /opt/local for Fink or MacPorts, respectively).

  • MacPorts: sudo port install sshfs
  • Fink: fink install sshfs

How to mount disks with sshfs

  • Create a mount point. (Either do this once in a permanent location or create something under /tmp.)
    mkdir $HOME/my_remote_mount
    The name can be anything you want, but don't have spaces in the name.
  • Simple version of the mount:
    sshfs remote_username@remote_host:/path/to/desired/dir $HOME/my_remote_mount
    e.g.,
    sshfs bobama@westwing.whitehouse.gov:/data/economic $HOME/my_remote_mount
    If your username is the same locally and remotely, you can omit it, as you would for plain ssh:
    sshfs westwing.whitehouse.gov:/data/economic $HOME/my_remote_mount

How to unmount disks

The man page for sshfs says to use fusermount -u usermount. This doesn't work for Macs because the fusermount command does not exist! Fortunately, there are various easy ways to unmount the disk:

  • From the command line:
    umount /path/to/mount/point
    e.g.,
    umount $HOME/my_remote_mount
  • From the Finder, drag the remote disk to the Trash
  • From the Finder, right-click (or control-click) on the remote disk and Eject.

Create aliases to ease future use

Once you have your sshfs setup the way you like it, it is highly recommended to capture that into an alias that you place in your .cshrc or .bash_profile startup file. It could be something like this:

tcsh version:
alias my_econ 'sshfs bobama@westwing.whitehouse.gov:/data/economic $HOME/my_remote_mount'

bash version:
alias my_econ='sshfs bobama@westwing.whitehouse.gov:/data/economic $HOME/my_remote_mount'

Please note that there are some other complexities and options related to using sshfs and MacFuse with Fink especially related to mid-2010 Macs (64-bit kernel) models and newer. (This is in contrast to sshfs and Fuse4X with MacPorts.) That information has been deleted to simplify this page, but if you run into trouble, please contact the ASD System Team.

David Friedlander
20 November 2009, simplified 16 Sep 2013
NASA Logo, National Aeronautics and Space Administration
Goddard