Linux – Automount sshfs using fstab without mount -a

fuselinuxsshsshfsUbuntu

Please consider following fstab line (line breaks for readability):

sshfs#user@192.168.1.123:/home/user/ 
/home/user/Server/ 
fuse    
auto,user,_netdev,reconnect,uid=1000,gid=1000,IdentityFile=/home/user/.ssh/id_rsa,idmap=user,allow_other  
0 

It works fine, but every reboot I need to use mount -a to mount the server (or click appropriate icon in Thunar to mount the thing)

Is it possible to mount my ssh directory straight-away on boot time?

I am using Xubuntu 13.10

Best Answer

The correct syntax for mounting sshfs shares at boot, in the /etc/fstab file is

 USERNAME@HOSTNAME_OR_IP:/REMOTE/DIRECTORY  /LOCAL/MOUNTPOINT  fuse.sshfs _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

It is an adaptation to non-systemd distros of the instructions contained here. If you are instead on a systemd distro (Arch, Fedora, OpenSUSE,...), the suitable instruction is:

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
Related Question