FUSE and sshfs in OS X

I’ve needed to mount multiple home directories from a single server, and have run up into one of the limitations in using Appletalk/AFP to do this, as via either OS X’s built in AFP or using Netatalk, one can only mount one home directory at a time. Additionally, Appletalk seems to be particularly chatty and thus slow, so I looked at using the Mac implementation of FUSE.

Using FUSE with sshfs, I can mount external volumes in the Finder over SSH. This has worked quite well, here is what I did to get this to work:

  1. Download and install both the MacFUSE Core and sshfs
  2. create a symbolic link to the sshfs command line tool so that I could create custom connect scripts:

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

  3. add /usr/local/bin to your path, if necessary, but editing your ~/.profile file if you have one, or ~/.bashrc. My .profile includes the following:

    export PATH=/usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH. After reloading your shell/terminal doing a which sshfs should output:

    $ which sshfs
    /usr/local/bin/sshfs

  4. create permanent directories where your volumes will be mounted from. OS X by default uses /Volumes, but if you choose to use this location you’ll find that you will need to manually recreate these directories each time, which is a pain. I choose:

    ~/mnt/[local_username]

    as the location to mount these volumes (where “~” is the home directory of the currently logged in user, and [local_username] is the username of the user currently logged in to the local OS X machine.). You can create these directories in the Finder, or by simply typing in:

    mkdir -p ~/mnt/[local_username]

    (the -p flag will create parent directories as needed, in this case “~/mnt”)

  5. I created a directory for storing my connect scripts. Each script includes the following:

    sshfs [remote_username]@netmusician.org: mnt/[local_username] -o ping_diskarb -o volname=[remote_username] -o reconnect -o follow_symlinks

    If you need to include an alternative SSH port number or any other special options, type in sshfs -h to see a list of available options. In the above example:

    • -o ping_diskarb: ensures that the new volume is immediately seen within the Finder
    • -o volname=[remote_username]: allows you to specify the name of the volume that will be mounted. In AFP, this is usually the name of the folder/home directory that will be mounted
    • -o reconnect: automatically attempts a reconnect if the volume is disconnected (e.g. if the network is no longer available, you put your machine to sleep, etc.)
    • -o follow_symlinks: since I use a lot of symbolic links, this option allows me to see the contents of these directories, rather than just displaying these directories/files as aliases
  6. optional: Setup public/private SSH keys to handle authentication in a non-interactive way (there are numerous guides available to assist in doing this)
  7. optional: Download Platypus and use this tool to create scripts that run in the background (i.e. do not demand window focus) and will execute your connect commands and automatically quit when completed

These volumes can be unmounted in the Finder, or by entering the following command in the Terminal:

umount /path/to/volume

(using the examples above, this would be ~/mnt/[local_username])

Published in: OS X | on February 7th, 2007 |

You can leave a response, or trackback from your own site.

4 Comments Leave a comment.

  1. On April 20, 2007 at 6:40 pm RaymonWazerri Said:

    Hey,
    I love what you’e doing!
    Don’t ever change and best of luck.

    Raymon W.

  2. On May 10, 2007 at 2:07 pm Diigo daily 05/10/2007 « Graham Perrin: fuzzy brained geek Said:

    [...] NetMusician Labs » Blog Archive » FUSE and sshfs in OS X [...]

  3. On May 18, 2007 at 10:47 am NetMusician Labs » Blog Archive » New version of MacFUSE aborts connections gracefully Said:

    [...] the time of writing my original post about using MacFUSE and SSHfs, an update to MacFUSE has been released. By default, this release deals with connection [...]

  4. On July 20, 2008 at 12:02 am Marco’s Blog - The Bayview Said:

    [...] FUSE and sshfs in OS X [...]

Leave a Comment