2

The solution to having a dynamic /nfs dir proved to be extremely simple: https://unix.stackexchange.com/a/584475/2972

I am wondering if I can do the same for sshfs.

Let us assume that I can run:

sshfs remote.server: /sshfs/remote.server

without entering passphase (I use ssh-agent).

Is it possible for me to make an sshfs.autofs config that will run this no matter what remote.server I enter?

So that no matter the remote.server this would work:

cd /sshfs/remote.server/dir-on-remote.server

as long as the manual sshfs remote.server: /sshfs/remote.server would work.

The only answers I have been able to find lists the exact servers to use. So if I want to use those solutions, I need to know the servers in advance.

I can see the use of that, but I would (just like with nfs) prefer a config, where I do not have the know the servers in advance, and which will use the login config from ~/.ssh/config - just like sshfs does when run manually.

I will be using this from my personal computer, so it is not a big risk if other users on my personal computer can see the password or can access the files as me.

Ole Tange
  • 35,514
  • https://unix.stackexchange.com/questions/294965/integration-of-afuse-user-level-automounter-with-sshfs-as-a-systemd-service-spaw/528699#528699 Basically same question with slightly different words – Alex Stragies May 22 '20 at 15:40

1 Answers1

1

A workaround is to use afuse:

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

It does not use autofs, but it seems to work.

Ole Tange
  • 35,514