I am trying to allow my laptop (Ubuntu 13.04) to access my PC (Lubuntu 13.04) hard drive through SSHFS. I'm using RSA keys to connect.

It works perfectly fine if I type this in the terminal:

sshfs my-PC:/a_folder /media/a_folder

But I would like it to be mounted automatically when I boot my laptop. So I added myself to the fuse group:

sudo adduser mynickname fuse

And I added the following line to my fstab file:

sshfs#mynickname@my-PC:/a_folder /media/a_folder fuse defaults,idmap=user,_netdev 0 0

When I boot the laptop, a_folder appears in the list of devices, but is not mounted. When I try to access it through Nautilus, it displays the following error:

mount: only root can mount sshfs#mynickname@my-PC:/a_folder on /media/a_folder

I get the same error if I try

mount /media/a_folder

in a terminal.

If I try

sudo mount /media/a_folder

I get

read: Connection reset by peer

I tried to add "allow_other" as an option in the fstab entry, and uncommented the related line in /etc/fuse.conf, but it didn't change anything.

The user "mynickname" is the owner of the folder /media/a_folder and has rwx permissions.

I looked at many threads on the internet about people with quite similar issues, but nothing worked so far. Usually, people can't even do

sshfs my-PC:/a_folder /media/a_folder

without getting an error, whereas this works fine on my laptop.

Any insight and tips will be greatly appreciated! Thanks.

EDIT: I solved this issue a while ago, but I forgot to update this post. So here is what is in my fstab:

sshfs#mynickname@my-PC:/a_folder /media/a_folder fuse noauto,_netdev,idmap=user,user,default_permissions 0 0

The key option to add was default_permissions if I recall. I had to add mynickname to the group to which belongs /a_folder/ on my-PC.

4 Answers 4


The problem you are experiencing is that your normal user has a correct setup for your identity file, while the root user has no idea what ssh key to use.

You can fix this by telling fstab what identity file/ssh key to use while trying to connect:

sshfs#user@host:/mnt/whatever/ /mnt/whatever/        fuse    user,_netdev,reconnect,uid=1000,gid=1000,IdentityFile=/home/USER/.ssh/KEYFILE,idmap=user,allow_other  0   2
  • Thanks for your answer. I already tried with the IdentityFile option, but I didn't specify the uid and gid options, so I will try that!
    – user171348
    Jun 30, 2013 at 17:04
  • Technically, you shouldn't need to use sudo if everything is set up correctly for a FUSE mount. Also, the uid/gid settings should only affect which user has rights to the files on your system.
    – earthmeLon
    Jun 30, 2013 at 17:06
  • So I just tried with uid, gid, IdentityFile, allow_other, all those options at the same time, and unfortunately it still doesn't work. Still the same error.
    – user171348
    Jun 30, 2013 at 17:16
  • Would you mind posting a sample of how you've gotten it written? You should be pointing to your private key, and not your public key.
    – earthmeLon
    Jun 30, 2013 at 21:28
  • 2
    So both methods didn't work. Still the same error. For the config file, I tried by specifying for the right host: user, hostname (tried both IP and name), identityfile. But it didn't work as well. So what I end up doing for now is that I added the command sshfs my-PC:/a_folder /media/a_folder in the startup applications. It's not as clean as using fstab, but it works well enough for now. Thanks for your help and your suggestions! If you think of something else, feel free to share, I'll appreciate it!
    – user171348
    Jul 1, 2013 at 13:17

To get real debug output you need to add both sshfs_debug and debug options to the mount:

sshfs#mynickname@my-PC:/a_folder /media/a_folder fuse defaults,idmap=user,_netdev,debug,sshfs_debug 0 0

With this you will get a lot of debug info to help you:

$ sudo mount -a
SSHFS version 2.5
FUSE library version: 2.9.2
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
executing <ssh> <-x> <-a> <-oClearAllForwardings=yes> <-2> <user@box> <-s> <sftp>
user@box's password: 
Server version: 3
Extension: posix-rename@openssh.com <1>
Extension: statvfs@openssh.com <2>
Extension: fstatvfs@openssh.com <2>
Extension: hardlink@openssh.com <1>
Extension: fsync@openssh.com <1>
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56, pid: 0
INIT: 7.22
remote_uid = 1001
   INIT: 7.19
   unique: 1, success, outsize: 40
unique: 2, opcode: STATFS (17), nodeid: 1, insize: 40, pid: 2771
unique: 3, opcode: LOOKUP (1), nodeid: 1, insize: 47, pid: 3371

In my case I discovered that my machine was only listed in .ssh/config, so it was unresolvable for root.

And BTW, you need to set uid and gid, since idmap=user only seems to work for the current user, which is root in this case.

  • The sshfs_debug and debug helped me. Turns out it was using the wrong port because fstab wasn't using the user ~/.ssh/config file. I also had to answer yes to accept the new host for that key. Thanks.
    – deanresin
    Feb 17, 2021 at 4:38

This problem can also occur when the host key of ssh changes.

Try to connect to the server via ssh (e.g. ssh username@hostIP). If the following error appears:


Follow the instructions in the error message to delete the old key and try to connect again via ssh. If the error does not appear any more, the sshfs connection should work.

  • "try to connect to the server via ssh" Make sure to do this as root if you're mounting the directory as root (which is what happens when automounting). A user's known_hosts file can be different from root's known_hosts file.
    – Shelvacu
    Dec 19, 2016 at 23:11

Full disclosure: old-school geek, but brand spanking new to the linux/open source world

First off, I'm still using password authentication because I haven't yet become savvy enough with RSA keys. That's nearing the top of the list though.

Relevant set-up info: Using a MacBook Pro with VMWare Fusion installed, on which I have Ubuntu server 10.04 LTS. Relying on Mac's terminal and SSH for almost all my server interaction

After botching a Drupal install, I rolled back to a prior snapshot and was suddenly unable to execute a command that I had just used moments previously: sshfs -o idmap=user -o allow_other user@mac.home:/Users/<username>/Documents ~/mountpoint

The issue is that the keys got out of sync. I don't know if I actually needed to do this on both my host and server, but I cleared out all of the local keys on each by first making a back-up of the known_hosts file, then editing the known_hosts file to remove entries.
On Mac, this file was located at: /Users/<username>/.ssh/known_hosts
On Ubuntu, this file is located at: /home/<username>/.ssh/known_hosts

So, to summarize, all performed from my Mac terminal, after starting up Ubuntu server:

cp /Users/<username>/.ssh/known_hosts /Users/<username>/.ssh/known_hosts.old
nano  /Users/<username>/.ssh/known_hosts
  # remove extra entries, save file
ssh <username>@ubuntu_server
cp /home/<username>/.ssh/known_hosts, /home/<username>/.ssh/known_hosts.old
nano /home/<username>/.ssh/known_hosts
  # remove extra entries, save file

Upon first SSH into each system, SSH prompts me to allow RSA keys to be added and all works thereafter.

Your Answer

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