Sshfs as regular user through fstab

Using option allow_other in /etc/fstab allows other users than the one doing the actual mounting to access the mounted filesystem. When you booting your system and mounting your sshfs, it's done by user root instead of your regular user. When you add allow_other other users than root can access to mount point. File permissions under the mount point still stay the same as they used to be, so if you have a directory with 0700 mask there, it's not accessible by anyone else but root and the owner.

So, instead of

sshfs#[email protected]:/remote/dir /work     fuse      user,_netdev,reconnect,uid=1000,gid=1000,idmap=user  0   0

use

sshfs#[email protected]:/remote/dir /work     fuse      user,_netdev,reconnect,uid=1000,gid=1000,idmap=user,allow_other  0   0

This did the trick for me at least. I did not test this by booting the system, but instead just issued the mount command as root, then tried to access the mounted sshfs as a regular user.


Also to complement previous answer:

  1. You should prefer the [user]@[host] syntax over the sshfs#[user]@[host] one.

  2. Make sure you allow non-root users to specify the allow_other mount option in /etc/fuse.conf

  3. Make sure you use each sshfs mount at least once manually while root so the host's signature is added to the .ssh/known_hosts file.

    $ sudo sshfs [user]@[host]:[remote_path] [local_path] -o allow_other,IdentityFile=[path_to_id_rsa]

REF: https://wiki.archlinux.org/index.php/SSHFS

Tags:

Linux

Sshfs