Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I frequently use ssh tunnels to access VNC sessions on remote machines, but this is on my laptop so the connections break when I put it to sleep for the night. If I then try to re-open the connection in the morning, I have to manually kill the ssh session, otherwise I get this error:

bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 1202
Could not request local forwarding.

The SSH command I'm using is this:

ssh -N -C -f -L 1202:localhost:5900 name@server

What's the best way to have the ssh tunnel die when it disconnects? Or reset?

share|improve this question
add comment

1 Answer 1

For automatic restarting of an ssh session, try using autossh

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.