1

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

2 Answers 2

2

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

0
1

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 :)

1
  • 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, 2010 at 16:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .