2

I am trying to auto mount a folder from my raspberry pi (/home/pi/server_folder), to a local folder (/home/my_name/raspberrypi). I can do this with sshfs (auto mount in fstab) when I set up a blank rsa key, but when I try to use an actual key, like 123, the raspberry pi filesystem wont mount. This is pretty obvious, since I have to supply the passphrase, but is there a way to have it ask for the passphrase when I first try to access /home/my_name/raspberrypi, or do something similar to that? Because if someone gets my laptop, they dont need to put a password or anything in to get access to my raspberry pi, if I leave the rsa key blank. I have looked into autofs, and autosshfs, but autosshfs won't download, and autofs doesn't explain how to mount with an actual rsa key (well, I haven't found a guide on how to). I'm using arch Linux, latest version. Here is the fstab entry:

pi@10.0.0.50:/home/pi/server_folder/ /home/my_name/raspberrypi  fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,IdentityFile=/home/my_name/.ssh/id_rsa,allow_other,reconnect 0 0

which is what arch wiki says to do (but doesn't explain very well).

2

Since SSHFS is based on FUSE, it's easier to use a non-root automounter. Use afuse, that's prety much what it was designed for. One-time setup:

mkdir ~/.afuse
ln -s .afuse/raspberrypi/server_folder ~/raspberrypi

To start the automounter:

afuse -o mount_template="sshfs %r:/ %m" -o unmount_template="fusermount -u -z %m" ~/.afuse

Make sure that the SSH_AUTH_SOCK variable is set when you start afuse, i.e. it must be started after ssh-agent. Run ssh-add to load the key into the SSH agent, and then you'll be able to access the SSHFS directories.

  • It doesn't work. It just creates a symlink called server_folder that doesn't exist. – Vityou Sep 6 '16 at 2:54
  • The symlink doesn't work, but the .afuse/raspberrypi/server_folder works. – Vityou Sep 6 '16 at 3:37
  • @Vityou The command I show creates a symlink called raspberrypi. Unless it's already an existing directory, in which case, remove it first. – Gilles Sep 6 '16 at 7:24
  • Of course, I always forget thing like those. Thanks. – Vityou Sep 6 '16 at 21:41
  • Is there any way to get it to work after a shutdown? – Vityou Sep 6 '16 at 21:50

Your Answer

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

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