How to convert sshfs command to fstab entry?

Solution 1:

You can use this syntax:

sshfs#USER@HOST:REMOTE_PATH LOCAL_PATH fuse defaults,allow_other 0 0

E.g.

sshfs#jverstrynge@devjverstrynge:/home/httpd /home/jverstrynge/httpd fuse defaults,allow_other 0 0

But this works only if you use ssh keys for authentication.

Solution 2:

From this source

this works for non systemd,see article for other config (Fedora, Arch, openSuse,...)

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

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

Solution 3:

Try autofs

create auto.master:

/mount /etc/auto.sshfs        uid=1000,gid=1000,--timeout=30,--ghost

create auto.sshfs - moviefolder:

fstype=fuse,rw,allow_other,noatime,port=54321,IdentityFile=/root/.ssh/id_rsa :sshfs\#[email protected]\:/var/www/html/moviefolder

You need to have ssh keys for this to work.