Automating SSH Forwarding
May. 3rd, 2010 06:25 pmI want access from my laptop to various services (web proxy and email) on my home network, even when I’m away. A convenient way to do this is to use SSH port forwarding. This is a nuisance to repeatedly initiate manually though; I would rather have my laptop run the SSH command automatically, and restart it after network outages.
(no subject)
Date: 2010-05-03 07:32 pm (UTC)yes(1)needs a --delay option :-)(no subject)
Date: 2010-05-25 07:42 pm (UTC)I'd also recommend
cond=true; while $cond; do cond="sleep 1"; ssh tunnels -N; done, 'cos that way interrupting sleep stops the loop, even if youdon't set -e.
Finally, if there's some hook for scripts to be called when the network
connection changes, it might be worth using OpenSSH's master mode: then ssh tunnel -Oexit when it needs to be kicked. Your shell loop will then reopen the connection. (This will kill all the forwarded connections, but they were toast anyway.) You'll need to add `ControlPath something' to the .ssh/config stanza to make this work. I don't think PuTTY has anything similar.