1

This question already has an answer here:

I am trying to auto mount a remote resource through sshfs but is not working for me. I have read all of this, this, this and this before ask to see if I can get the solution for my issue but it didn't work.

So here is what I have done so far:

  • Added the following line to /etc/fstab:

    <username>@remote_host_ip_address:remote_path host_path fuse.sshfs delay_connect,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/<username>/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000 0 0
    
  • I have ssh into the remote host once so it gets added to the /home/<username>/.ssh/know_hosts file. I have checked after and the remote host is there

  • I have run the command sudo mount -a

When I change directory and check the local path something goes wrong since I can not cd into it and it looks like:

enter image description here

What I am doing wrong here? What I am missing?

marked as duplicate by Gilles ssh Sep 21 '16 at 22:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Rather than using system-wide /etc/fstab, I suggest using afuse. It's mentioned in passing in the Arch wiki you link, but it's also included in Fedora. This runs in your user session and can therefore either use ssh-agent or prompt for a password.

It also will only mount on demand, and can be configured to unmount after a timeout, which is particularly valuable if your network isn't perfectly solid.

afuse -o intr -o timeout=300 \
  -o mount_template='sshfs -o intr -o follow_symlinks -o reconnect <username>@<remote_host_ip_address>:<remote_path>:%r %m' \
  -o unmount_template='fusermount -u -z %m' \
  ~/<localmount>

... making sure to replace the <things in brackets> with your local options. The afuse docs give a few other options that you can use - I like -o populate_root_command, but it's not necessary.

There are a number of different ways to run this automatically on login; it depends on your desktop environment, but basically you'd have to add the afuse line to autostart like any other such command.

  • Ok, but afuse command can not be used on boot, right? If can be used can you add the proper line to your answer? – ReynierPM Sep 21 '16 at 18:12
  • Do you need it to be available on boot? Why? – mattdm Sep 21 '16 at 18:15
  • 1
    Well the idea is not to run the command all the time, for example let's said I run the command once, then for some X reason the computer restart and I need to login again, I would like to have the shared folder mount by default but anyway if this is not possible then what's the right command for mount the shared folder using afuse? The example on the Wiki link is not so helpful – ReynierPM Sep 21 '16 at 18:17
  • 1
    Afuse will mount the sshfs filesystem automatically whenever you access it. I'll add some details. – mattdm Sep 21 '16 at 18:18

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