Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've just started playing around with SSH tunnels today, but I'm stick at a bit of a silly point (I think)... Probably just missing something obvious but here goes:

I've got two linux servers and a single windows client (server1, server2, client). I've set up server1 to create a reverse ssh tunnel to server2, like so:

ssh -nNfR 8022:localhost:22 user@server1

After which I can successfully get a shell on on server1 using:

ssh -p 8022 localhost

Logically, this leads me to think that I should be able to create a putty ssh connection to server1:8022 and get a shell for server2, but I get a connection refused error. Anyone know what I'm missing or am I entirely on the wrong track :)

Thanks

share|improve this question

2 Answers 2

up vote 2 down vote accepted

This is a common problem. You need to enable port access on the server. Modify GatewayPorts to yes in /etc/ssh/sshd_config.

see man sshd_config under GatewayPorts.

You may also need to specify a bind address to your tunnel setup:

ssh -nNfR *:8022:localhost:22 user@server1

to bind to all interfaces.

see man ssh under -R

share|improve this answer
    
Thanks, this solved my problem (needed to do both) –  LorenVS Jul 20 '10 at 16:40

You are using

 ssh -nNfR 8022:localhost:22 user@server1

That is basically saying 'open the 8022 port on server1 connecting to localhost port 22', but 'localhost' on server1 its... server1 :) try with:

 ssh -nNfR 8022:server2:22 user@server1

Also, when you use 'localhost' on the first command you bind your port to the loopback interface (127.0.0.1) that doesn't accept connections from outside, try it with the server1 hostname or IP to check :)

share|improve this answer
    
After playing around with it a bit, I believe your first suggestion is incorrect, although your second suggestion was part of the solution. –  LorenVS Jul 20 '10 at 16:41

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.