Search code examples
ubuntuubuntu-16.04sshfs

How to configure sshfs in /etc/fstab / alternatives to sshfs


On my Ubuntu 16.04 machine I can execute the following command

sshfs -o sshfs_debug -p 22 myuser@myserver:/homes/user /home/user/test -C -o allow_other

This will mount the remote directory /home/user on my local machine as /home/user/test.

I was wondering if this can be done using fstab in some way. Of course the mount must delayed because network will not be available on reboot.

The thing is that I don't even get to that hurdle. The above command is simple enough but when one tries to add that to fstab this add a lot of complexity for some reason

myusers@myserver:/homes/user  /home/user/test  fuse.sshfs comment=sshfs,defaults,transform_symlinks,users,exec,auto,allow_other,_netdev,delay_connect,uid=1034,gid=100 0 0

There are a number of examples on the internet but none work. The above command also doesn't work. The share is mounted without errors but if I try to access this only produces error message example is

myuser:~]↥ $ ls test 
ls: cannot access 'test': Input/output error
[myuser:~]↥ 2 $

Is sshfs used in fstab? Should that work? Are there alternatives for sshfs? It doensn't to be stable yet. Documentation and examples vary in many ways.


Solution

  • To troubleshoot look in system log. I ended up with the following entry. I think you need to always specify the identity file

    myuser@myserver:/homes/user  /home/user/test fuse.sshfs _netdev,user,idmap=user,transform_symlinks,identityfile=/home/myuser/.ssh/id_rsa,allow_other 0 2