From another SO question, I understand I should create an entry in fstab to permanently mount an access to a virtual machine.

I am not Linux expert. The magic command which allows me to perform this from a terminal is:

sudo sshfs -o idmap=user -o allow_other -o nonempty jverstrynge@devjverstrynge:/home/httpd /home/jverstrynge/httpd

When I check the above SO question, I see an entry looking like this:

/media/mybook/laptop_backup /export/laptop_backup none bind 0 0

Can someone explain how to transform the CLI command into an entry in fstab?


3 Answers 3


You can use this syntax:

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


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

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

  • 4
    If you intend to use the allow_other mount option like the answer above suggests, be aware that the Linux kernel has an unresolved security bug that affects FUSE. See github.com/libfuse/libfuse/issues/15
    – MountainX
    Feb 11, 2018 at 8:51
  • 1
    Similar to the answer below regarding autofs, the options field of fstab (defaults,allow_other above) may include any option in ssh_config like: IdentityFile=some_file, etc. Perhaps choosing only aes256 cypher since 128 is default or setting up a PKI provider for smartcards (btw for US federal users you can set up standard Id smartcards, just don't forget revocation.) Finally two notes (untested) considere /etc/ssh/sshd_config and the "delay_connect" option to speed up boot.
    – uDude
    Apr 14, 2020 at 17:54
  • 3
    This works with root's ssh configuration. Is there a way to make it use my user's? I'd like it to use my host configuration without having to copy it over.
    – Paul
    Jul 6, 2020 at 13:54
  • 1
    @Paul You can specify a custom SSH command. Building on the posted example: sshfs#jverstrynge@devjverstrynge:/home/httpd /home/jverstrynge/httpd fuse defaults,_netdev,allow_other,ssh_command=ssh\040-F\040/home/jverstrynge/.ssh/config 0 0 I had to format it like this to get it to recognize the hostname from the config file: jverstrynge@devjverstrynge:/home/httpd /home/jverstrynge/httpd fuse.sshfs defaults,_netdev,allow_other,ssh_command=ssh\040-F\040/home/jverstrynge/.ssh/config 0 0 Note that the \040 in both examples is an octal escape sequence for the space character. Jan 19, 2023 at 16:49
  • 1
    The sshfs#USER@HOST syntax was deprecated in latest FUSE implementations. Now it's : [email protected]:/ /mnt/XSI/srvs/e.f.g.h fuse.sshfs + options
    – Daniel J.
    May 5, 2023 at 15:15

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
  • USERNAME occurs twice. In the first case it is obviously remote - in the second (identity file) it is local I guess. Mar 27, 2019 at 9:38
  • yes correct, first is remote user, second is the local path
    – altagir
    Mar 28, 2019 at 17:23
  • 1
    Works fine in Ubuntu. I only had to remove the uid and gid part. Accessing files in my file manager without root is possible which is nice.
    – matt3o
    Apr 10, 2020 at 8:23
  • @matt3o note that under Ubuntu: uid=1000,gid=1000
    – allanlaal
    Feb 5, 2022 at 8:46
  • Doesn't work for me. When I execute mount -a after having written all of that, the command just hangs indefinitely, and there is no logs in journalctl about that.
    – Hi-Angel
    Aug 29, 2022 at 13:45

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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .