Remote port forwarding with Putty

port-forwardingputty

When I create a remote port forwarding tunnel with Putty, a remote port opens on interface with ip 127.0.0.1. On the remote host I'm able to nc localhost RPORT and forwarding works, but I'm unable to connect with nc RHOST RPORT. The problem is, that RPORT gets open on wrong interface — localhost, instead of the public IP interface.

How can I setup remote port forwarding, so that I can connect from the internet, to RHOST:RPORT?

On RHOST, netstat -an | grep RPORT returns tcp 0 0 127.0.0.1:RPORT 0.0.0.0:* LISTEN

Best Answer

GatewayPorts needs to be set to on in sshd_config for the far side to allow others to connect to the forwarded port or you need to check 'Remote ports do the same (SSH-2 only)' in the PuTTY GUI to request that setting of the session.

If you wanted to forward from other hosts via PuTTY you need to check the 'Local ports accept connections from other hosts' setting.