FSTab: How to mount an sshfs volume that tolerates ip number changes and connection errors

published Dec 25, 2019 10:20   by admin ( last modified Dec 25, 2019 10:26 )

…and can only be accessed by one user. Also this is on Ubuntu and I guess should work on other systemd-based distros. Just installed and it works, we will have to see how it performs. Here is the whole shebang, I did not break it up with line continuation characters because it already looks a bit like line noise:

remote-username@server.example.com:/path/on/remote/to/folder /path/to/local/mount/point  fuse.sshfs noauto,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,x-systemd.automount,_netdev,user,idmap=user,follow_symlinks,identityfile=/home/localuser/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000 0 0

1000 is the numerical id of the user that should be able to access the volume. You can check your uid and gid with the id command :

$username> id
uid=1000(username) gid=1000(username)


Also, while being root make sure that the server ends up in root's known hosts file:

$username> sudo -i
#root> ssh remote-username@server.example.com

That should trigger an add to known hosts dialog.

Also, you need to have sshfs installed:

$username> sudo apt install sshfs