SSH – Troubleshooting Remote Forward Success but Test from Remote Site Not Working

linuxport-forwardingsshssh-tunnel

Took me a while to figure this out, but finally got remote port forwarding to work with ssh as follows:

ssh -N -i /etc/ssh/id_rsa [email protected] -R 8080:localhost:80 -C -v

The local server uses a private key to connect to the remote server which has a public key configured. Able to authenticate successfully, no errors in the log. The last line that ssh prints is:

debug1: remote forward success for: listen 8080, connect localhost:80

I tried testing this from my public site, as follows:

However, nothing happens – still see this line:

debug1: remote forward success for: listen 8080, connect localhost:80

If I test locally on the remote server using http://127.0.0.1:8080, it works fine.

NOTE: The following is set in sshd_config on the remote server:

  1. AllowTcpForwarding yes
  2. GatewayPorts yes

Not sure what I am missing…

Best Answer

Quote from man ssh

By default, TCP listening sockets on the server will be bound to the loopback interface only.This may be overridden by specifying a bind_address. An empty bind_address, or the address ‘*’, indicates that the remote socket should listen on all interfaces. Specify‐ ing a remote bind_address will only succeed if the server's GatewayPorts option is enabled (see sshd_config(5)).