Quantcast
Channel: Active questions tagged mount+fstab - Ask Ubuntu
Viewing all articles
Browse latest Browse all 699

Automount remote filesystem on reboot without password with sshfs

$
0
0

What I Want:

  • boot up my system (in this case ubuntu 18.04 on a laptop)
  • have access to a remote filesystem via /home/<user>/mnt/remote-HD0

What I have tried

  • edit /etc/fstab with sshfs command
  • edit /etc/crontab with @reboot tag and run a script to execute sshfs command
  • tried custommade systemd service to run a script to execute sshfs command

I always used absolute paths and also passed a sshkey (which is copied via ssh-copy-id to the remote system) so that I dont have to type password. I also uncommented user_allow_other of /etc/fuse.conf.

What does not work?

If I type the cmd

sshfs -o allow_other,delay_connect,reconnect,identityfile=/home/<user>/.ssh/id_rsa <remote@filesystem>:/mnt/HD0 /home/<user>/mnt/remote-HD0

in a terminal or run it via an executable script, it works as intended. I have access to the filesystem and don't have to type pw. However when i use the fstab version with

sshfs#<remote@filesystem>:/mnt/HD0    /home/<user>/mnt/remote-HD0    fuse    defaults,_netdev,allow_other,identityfile=/home/<user>/.ssh/id_rsa 0 0

it does not mount until i use

 sudo mount -a

and get asked to type pw for ssh connection and press enter for an empty passphrase....

With the other two attempts (crontab & systemd) it either does'nt work at all or it's broken, because /home/<user>/mnt/remote-HD0 is not accessible, i.e.

ls /home/<user>/mnt/remote-HD0
ls: cannot access 'remote-HD0': Input/output error


ls -la
drwxrwxr-x  4 <user> <user> 4096 Jun 19 13:46 .
drwxr-xr-x 38 <user> <user> 4096 Jun 19 15:22 ..  
d?????????  ? ?      ?      ?    ?            remote-HD0

So something went wrong with the mounting process. There are (likely) two issues :

  1. The sshfs command is executed before the network is online (which I tried to take into account using the crontab and systemd service)

  2. Even with using a sleep command, this problem with the "Input/output error" occurs.

I did spend already some hours trying to fix this and learned quite a bit about all the methods used, but at this very moment I just hope for a solution so that I can move on (preferably using fstab or systemd, as it seems to be the correct attempt).


Viewing all articles
Browse latest Browse all 699

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>