I recently discovered sshfs; which is a useful way to mount remote systems via ssh.
I wanted to have some systems mounted automatically on my laptop whenever I am online but not have any timeouts or attempts to connect when I am not. This ruled out simply adding a line or two to my .bashrc file or the /etc/fstab file.
I already use the whereami package to selectively mount nfs shares and do other things depending on my location so it was just a matter of editing the
/etc/whereami/whereami.conf file to include the following:
#mount /media/server1 =home sudo -u kguest sshfs server1.example.com: /media/server1 -o workaround=rename #mount /media/server2 =home sudo -u kguest sshfs server2: /media/server2 -o workaround=rename
The ‘home’ location is defined in my
/etc/whereami/detect.conf file if the access point at home is detected:
testap example-ap-name home,wdhcp
Combined, these mean that if the whereami script detects an access point named example-ap-name (original isn’t it?) then those remote systems are mounted into the /media/server1 and /media/server2 directories.