I want to sshfs from my Linux machine (Ubuntu 18.04.2 LTS) to my MacBook. I could do it at command line with

sshfs jczhang@ /home/jczhang/mysharedfolder

It worked perfectly. Since I wanted to mount the shared folder automatically at boot time, I put this in /etc/fstab.

jczhang@ /home/jczhang/mysharedfolder fuse.sshfs delay_connect,_netdev,user,uid=1000,gid=1000,IdentityFile=/home/jczhang/.ssh/id_rsa,allow_other 0 0

Here, 1000 is my uid and gid in Linux. After reboot, I found the directory was mounted but I could not access the directory.

ls -l
d?????????  ? ?       ?              ?            ? mysharedfolder/

cd mysharedfolder
-bash: cd: mysharedfolder: Input/output error

mount status had
jczhang@ on /home/jczhang/mysharedfolder type fuse.sshfs (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,allow_other,_netdev,user)

I did not know why sshfs kept using user_id=0,group_id=0. I tried different combinations of uid=1000,gid=1000 and idmap=user. None worked. I umounted the shared folder and did "mount -a". It still did not solve the problem.

I used the default SSHFS version 2.10. Later, I upgraded it to version 3.5.2. Nothing changed.

Does anyone know a solution? Thanks.


This problem drove me mad. Since this shared folder is for my personal use and sshfs works at command line, I find a workaround. In .bashrc, I put if ! [ -d /home/jczhang/mysharedfolder/flagfile ]; then sshfs jczhang@ /home/jczhang/mysharedfolder -o idmap=user,uid=1000,gid=1000 fi flagfile is a file to tell whether the folder is already mounted. Every (first) time I login to Linux, the folder is automatically mounted for me.

It works great!

  • Here is what works for me: ` stephen@nnn.nnn.nnn.nnn:/export/inbox /mnt/inbox fuse.sshfs nofail,x-systemd.automount,x-systemd.requires=network-online.target,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/stephen/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000,exec 0 0` This shows up as user_id=0,group_id=0. I don't know why, but maybe try this option string. – Stephen Boston Jun 27 '19 at 18:04
  • Tried but did not work. d???? disappeared this time and I have "drwxr-xr-x 2 root root" It looked OK. But "cd mysharedfolder" gave "Too many levels of symbolic links". Also, mount showed a weird "systemd-1 on /home/jczhang/mysharedfolder type autofs (rw,relatime,fd=92,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=18368)" – Junchao Zhang Jun 27 '19 at 18:37
  • This might be a good candidate for autofs - see for example Autofs and sshfs – the perfect couple. You might want to look at the mountpoint function instead of your flagfile. – steeldriver Jun 27 '19 at 20:38

I have this exact setup working:

My OS as 18.04.2:

] lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

My SSHFS version:

] sshfs -V
SSHFS version 2.8
FUSE library version: 2.9.7
fusermount version: 2.9.7
using FUSE kernel interface version 7.19

Creating the base:

] sudo mkdir /path/to/mount
] sudo chown $USER: /path/to/mount
] sudo nano /etc/fstab
] ssh REMOTEUSER@HOSTNAME touch /path/to/share/testfile

/etc/fstab entry: (you can remove the port entry)

REMOTEUSER@HOSTNAME:/path/to/share /path/to/mount fuse.sshfs port=PORT,_netdev,follow_symlinks,identityfile=/home/LOCALUSER/.ssh/RSAKEY,allow_other,uid=1000,gid=1000 0 0

Testing mount:

] sudo mount -a
] mount | grep HOSTNAME
REMOTEUSER@HOSTNAME:/path/to/share on /path/to/mount type fuse.sshfs (rw,relatime,user_id=0,group_id=0,allow_other,_netdev)
] ls -l /path/to/
drwxr-xr-x 1 LOCALUSER LOCALGROUP 4096 Jun 28 09:20 mount/
] ls -l /path/to/mount/testfile
-rw-rw-r-- 1 samh samh 0 Jun 28 10:45 /path/to/mount/testfile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.