I got two hints regarding the keeping alive of ssh connections in response to my recent post. Thanks for those. The problem I had in mind is a little more tricky, unfortunately. Imagine the following:
I get up in the morning, perhaps check my e-mail quickly. To do this, I wake up the Powerbook, establish the ssh tunnel, check e-mail. Then I have breakfast, get to my department with the Powerbook, hook it up there, want to connect to my e-mail again and have to first close the old ssh session (it will block the local port even after the connection to the remote machine was broken), open a new one for fresh port forwarding. Then I go to a seminar, sending the Powerbook to sleep. When I come back, the connection has timed out. Rinse and repeat.
As the task is pretty trivial and rather repetitive, it would be perfect for a computer to do it: Kill the old ssh task and start a new one whenever the port forwarding stopped working a new session is needed. Pretty simple, I think. But I don't know how to achieve it. Bugger.
Here’s a perl script I use on OS X: http://improbable.org/chris/Software/SecureMail
Note that it relies on having a working ssh-agent (mine is started on login and thus inherited by everything I run) or using a public key w/o password (which is riskier). You’ll have to edit the SSHCMD line at the top to change the ports to forward and the remote systems.
Many protocols work better if you enable compression but that hurts latency for normal shell sessions. I put this in my .ssh/config file so it only applies to the remote webserver (I could do it on the command-line but this way things like my rsync scripts benefit, too):
Host web1.qwknetllc.com User webserveruser IdentityFile ~/.ssh/secret_key Compression yes CompressionLevel 9
I should also have mentioned that I have a global “KeepAlive yes” and that the way SecureMail does a double-fork() means you can start it from something like FruitMenu or close a terminal window after starting SecureMail without having SecureMail die or go zombie on you.
I don’t understand all of what you say, but it definitely sounds interesting. What’s the ssh-agent all about? I seem to vaguely remember that it’s different from Bill’s program.
The link you gave, gives 403 Forbidden, btw. Thus I couldn’t simply give your script a try.
Received data seems to be invalid. The wanted file does probably not exist or the guys at last.fm changed something.