Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

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.

share|improve this answer

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
share|improve this answer
    
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 '13 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 '13 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 '13 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 '13 at 21:28
    
You also must put your user in the fuse group and restart your machine in order for the allow_other to work. –  earthmeLon Jun 30 '13 at 21:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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