Ssh – port forward to an established reverse ssh tunnel

port-forwardingssh

I have three computers, A, B and C. A has initiated a reverse ssh tunnel to B.

ssh  -nTNx -p 443 -R 22222:localhost:22 [user]@[server]

If I log in to B, I can use 'ssh -p 22222 localhost' and I get a login prompt for A.
If I try 'ssh -p 22222 [public IP of B]', it doesn't work

What I would like to be able to do is have C connect to A without needing to login to B. So from C I could 'ssh -p 22222 [public IP of B]' and I would get the login prompt for A.

I am using debian and shorewall and I have a basic understanding of how things work. I have tried various combinations of REDIRECT and DNAT rules, but haven't had any luck. I have tried using the same port (22222) and a different port (forwarding 22223 from C to 22222 on localhost).

Any ideas?

Best Answer

See the "Remote port forwarding for anyone at work !" section of this webpage. The article suggests that you should add the

GatewayPorts yes

option to your sshd_config on your HostB. That should cause the remote port forwarding on your HostB to listen on all of its network interfaces.

Related Topic