After being inspired by Anil, I have also managed to eliminate the incredibly annoying way SSHKeychain creates modal alert boxes which get buried under every other window on your desktop, and prevent you from interacting with it before you dismiss them.
There are two aspects to my hackery. One is to introduce a very simple
sleep() call before the application responds to the
kIOMessageSystemHasPoweredOn message, which gets posted after a system has awoken from sleep. This stops any SSH tunnels you have defined from being initialised before the system has re-associated with its network properly. This is an issue more frequently encountered with wireless networks, which are slightly slower to respond, and the main reason I started this work. I was sick of hunting for, and clicking away endless boxes informing me that “The tunnel has unexpectedly terminated and could not be restarted.”
I have also managed to hack Growl support in to the application. The new alert panels look like this:
Incidentally, it’s worth mentioning here that I find SSH tunnels very very useful for being able to send email via SMTP no matter which network you are connected to. I have a permanent tunnel set up from localhost:2525 to the recoil.org servers, and it means I only need one outbound server definition within Mail.app.