Friday, February 25, 2005

SSH Tunnelling

I just setup a SSH tunnel from my box to a distant server. It worked fine, with one minor problem.

When I first tried the tunnel, I would get timeouts on the client, and this message on the server session:

channel 3: open failed: connect failed: Connection timed out

What I didn't realize is that in the command ssh -TCN -L 1234:baz.bar.com:2345 foo@baz.bar.com, the first 'baz.bar.com' is relative to the host machine, not the client. As a result, the command connected to the server, but the port forwarding didn't work because the server didn't know about baz.bar.com. Using ssh -TCN -L 1234:localhost:2345 foo@bar.com did the trick, since the server did know about localhost relative to itself, and the client process connected immediately.

2 Comments:

Blogger WheresGeorge said...

Wow, who would have thought that 8 years later your post would be found, and have the solution to my exact problem. Thank you. I spent the last 5 hours trying to make a simple SSH tunnel work (something I've done hundreds of times before), but for some reason, this time it was failing with very little helpful error messages. Turns out it was the EXACT problem (and solution) you stated, so I just wanted to say "thanks".

2:12 PM  
Blogger Anton Filippovich said...

same thing! thx a lot!!!

3:56 PM  

Post a Comment

<< Home