I want to use sshfs to mount a directory from the remote system automatically when I make the first ssh connection and to unmount the directory when I finally disconnect.
I currently use ssh's ControlMaster facility so that I only have to enter the password the first time I connect to the remote. I do often have several ssh connections running simultaneously.
I guess I can have a script run from ssh when it connects (I seem to remember there's a way to do this) and the script can check for the existence of the mount before trying to do it.
However I'm not sure how to clear down the mount when the last ssh (the master one) exits.