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:
- Download and install both the MacFUSE Core and sshfs
- 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 - 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 awhich sshfsshould output:$ which sshfs
/usr/local/bin/sshfs - 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”)
- 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_symlinksIf you need to include an alternative SSH port number or any other special options, type in
sshfs -hto 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
- optional: Setup public/private SSH keys to handle authentication in a non-interactive way (there are numerous guides available to assist in doing this)
- 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])
You can leave a response, or trackback from your own site.
Hey,
I love what you’e doing!
Don’t ever change and best of luck.
Raymon W.
[...] NetMusician Labs » Blog Archive » FUSE and sshfs in OS X [...]
[...] 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 [...]
[...] FUSE and sshfs in OS X [...]