Getting sshfs & automount to play ball on OSX El Capitan

So, I’ve been googling a lot and found http://virtuallyhyper.com/2013/07/mount-various-file-system-with-autofs-on-mac-os-x-mountain-lion/ which is a pretty good how-to to the utterly undocumented automounter of OSX.

BUT. This doesn’t exactly work anymore. Since autofs will create a mountpoint owned by root and sshfs will be called as your user, you’ll need to think a bit outside the box. First, instead of a /sbin/mount_sshfs symlink create a small script:

and chmod +x and chown root it. Now you probably already know what’s up. Use visudo to add this to your sudoers file:

… and don’t forget to tell fuse/sshfs to mount your share as your own user (I’m assuming uid 501 and gid 20 here, use the command id to inspect your own environment)

This is basically the missing glue to the how-to I linked above. Don’t forget to sudo automount -vc, and unmount/mount the directory with the share to activate the changes.

Do not forget that the ssh keys used are NOT the ones of your user, but those of root. You also need to at least once log in with the root user on the host, so the host is added to known_hosts, without which the mount won’t work.

Also,

APPLE, WHAT THE FUCK, FIX THIS.
Like what you read? Give Philip P. a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.