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

sshfs#[email protected]:/home/user/ 

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

5 Answers 5


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
  • It looks like almost exactly same fstab line as mine (except permissions and symlink option) Anyway I tried it, and no success. I still have to exec mount -a after boot
    – user21886
    Nov 4, 2013 at 11:41
  • That's funny, it just worked for another user superuser.com/questions/666739/…. Have you checked that you are user 1000,1000, and that your key in id_rsa? Nov 4, 2013 at 12:22
  • Yes, and it is working 100%, but I need to run mount -a after boot. I'm concidering to add mount -a to autostart
    – user21886
    Nov 4, 2013 at 12:50
  • It is possible this occurs before your network comes up after execution of mount at boot. Try adding these two lines in rc.local sleep 10: mount -a Nov 4, 2013 at 13:23
  • 2
    read: Connection reset by peer
    – Dims
    Jun 24, 2019 at 15:21

Try using the delay_connect option.

Full /etc/fstab line:

USER@HOSTNAME:/REMOTE/ /LOCAL/ fuse.sshfs delay_connect,_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

Those delay_connect, _netdev, ... are correct but won't work unless you tweak the networking to come up exactly in (or before) that small time window, when the /etc/fstab is being processed. When the processing is over, and networking comes up later, you have to use the mount -a (or friends).

In most cases (and mine also) the network-manager caused the problem, since it brings the network up after login by default. It can be tweaked to bring it up earlier at boot time. If I remember correctly, all you need to do is to check the option Available to all users in the connection properties dialog (or, if you prefer command line, create manually the connection in /etc/NetworkManager/system-connections).


Based on this ubuntu help page and my tries with Debian 9, I make it work and have right file permissions with this fstab entry :

sshfs#user@host:/remote/path /local/path fuse delay_connect,defaults,idmap=user,IdentityFile=/local/path/to/privatekey.pem,port=22,uid=1001,gid=1002,allow_other 0 0

delay_connect ensures fstab does not mount remote folder before network interfaces are up.

You can change port, uid, gid to match your local needs. To figure out my uid / gid I simply used $ id when logged with the right user.

allow_other is there to allow other users / groups to access the mounted directory; Even with the right /local/path permissions (for example 777), this is needed if you want a different user (different from the one mounting the sshfs) to access the mounted directory.

Other options can be found in the sshfs manpage

  • The options can indeed be found in the manpage, however what is not clear to me is how to write those options in the fstab file. Do you just write them without the -o, but otherwise identical, in the comma separated list of options of fstab?
    – Andyc
    Jul 29, 2021 at 10:44

The answer of @MariusMatutiae is good, but I think it lacks a very important point. In the given link to the Arch Wiki it says.

And most importantly, use each sshfs mount at least once manually while root on the client machine so the host's signature is added to the client's /root/.ssh/known_hosts file. This can also be done manually by appending one or more of the the SSH server's public host keys (the /etc/ssh/ssh_host_*key.pub files) to /root/.ssh/known_hosts.

Actually you don't have to mount your sshfs while root for that to work. It's enough to sudo ssh yourserver for it to add the public key to root.

I had it set up in an Ubuntu server a couple of years ago and I remember struggling with that, but didn't remember what the solution was. Now I switched to OpenSUSE and I struggled again for the same reason, until I decided to read that Arch Wiki page. So maybe this helps someone else.

You must log in to answer this question.

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