0

I edited the file /etc/rc.d/rc.local and added the following lines in order to mount a remote directory through sshfs at boot time:

su user -c "/usr/bin/sshfs -o idmap=user -o reconnect -o allow_other -o uid=500 -o gid=500  user@remote:/home/shares/allusers /home/user/mnt"

The problem is that is not mounting the directory on startup but when I execute this command manually after logging in everything works as expected an the directory is mounted.

Any suggestions?

glarkou
  • 149
  • 1
  • 8

3 Answers3

1

Try adding

sshfs#user@remote:/home/shares/allusers /home/user/mnt" fuse defaults,idmap=user

to /etc/fstab

test it with mount -a if ok, reboot

radoslawc
  • 51
  • 3
0

rc.local will be executing as root so you'll need to make sure root has an SSH key that will work with the specified user at the remote host, or specify the key to use with -o IdentityFile=/home/user/.ssh/my_key*.

*Couldn't test this as it looks like my version of sshfs is too old to have the option.

James Yale
  • 5,182
  • 1
  • 17
  • 20
0

Instead of adding mount -a to rc.local as suggested by previous answers one can simply add delay_connect as a fstab option.

(This could have been a comment, but my rep count is too low)

ucyo
  • 101