How to use /etc/fstab and/or automount with sshfs on OSX?

4

1

I'm attempting to automount a directory from a remote Ubuntu machine on my Mavericks Mac. SSHFS works perfectly when mounted manually, in many different ways. The standard sshfs mount works great:

sshfs user@desk:/home/user desk 

and I can even use mount:

sudo mount -t sshfs -o allow_other,IdentityFile=/Users/user/.ssh/nopass_id_dsa user@192.168.1.2:/home/user desk

(I followed the OSXFuse automounting instructions to set up mount_sshfs)

I want to turn this into an automount. The easiest, recommended by OSXFuse way is to turn the above mount command into an /etc/fstab entry:

user@192.168.1.2:/home/user    /Network/desk   sshfs   allow_other,IdentityFile=/Users/user/.ssh/nopass_id_dsa 0 0 

but that doesn't work:

Network $ sudo mount desk
mount: desk: unknown special file or file system.

Similarly, if I do sudo automount -vc then I either get a long timeout or an unhelpful "Operation not permitted" error when I try to enter the mount point, depending on how I play with the formatting of fstab options. I get the same errors when I try to set up an automount map, as described here.

What's wrong with my fstab entry? Or, how else can I automount sshfs on OSX?

(I'm on 10.9.5 with sshfs 2.5.0 from homebrew)

Adam

Posted 2014-10-23T18:27:34.537

Reputation: 162

To (re)mount all mount points from /etc/fstab a simple mount -a are enough. – UsersUser – 2014-10-23T18:56:58.240

@UsersUser that implies mounting via fstab works. It doesn't. – Adam – 2014-10-23T19:24:00.317

Answers

2

Due to a bug in OSXFuse, this is necessary for the allow_other flag to work:

sudo sysctl -w osxfuse.tunables.allow_other=1

This may or may not fix the fstab issue, but it does work with a direct map. Here's how I set mine up.

Add this line to /etc/auto_master:

/-                              auto_ssh          -nobrowse,nosuid

create /etc/auto_ssh:

/Users/USER/MOUNT_POINT          -fstype=sshfs,allow_other,idmap=user,cache=no          USER@LINUXMACHINE:/home/USER

(assuming you have passwordless keys set up.)

Tell autofs about your changes:

sudo automount -vc

To make the osxfuse.tunables.allow_other change survive a reboot:

Put the following in /Library/LaunchDaemons/sysctl.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>Label</key>
 <string>sysctl</string>
 <key>ProgramArguments</key>
 <array>
   <string>/bin/bash</string>
   <string>-c</string>
   <string>/Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs; /usr/sbin/sysctl -w osxfuse.tunables.allow_other=1</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>

Load the plist with:

launchctl load /Library/LaunchDaemons/sysctl.plist

Adam

Posted 2014-10-23T18:27:34.537

Reputation: 162

0

try adding the below format in fstab:

USERNAME@HOSTNAME_OR_IP:/REMOTE/DIRECTORY /LOCAL/MOUNTPOINT fuse.sshfs x-systemd.automount,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/USERNAME/.ssh/id_rsa,allow_other,default_permissions,uid=USER_ID_N,gid=USER_GID_N 0 0

If above not working check b adding delay_connect in that content and check.

Also

see Macfusion. It it is also beneifical to read OSXFUSE's FAQ for their justification for making Macfusion a requirement for SSHFS user space filesystems.

http://macfusionapp.org/

vembutech

Posted 2014-10-23T18:27:34.537

Reputation: 5 693

Same errors. Can you link to said FAQ? Neither the old MacFuse nor the current OSXFuse FAQ mention Macfusion at all. https://github.com/osxfuse/osxfuse/wiki/FAQ

– Adam – 2014-10-23T19:16:25.130