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:
- http://www.somewhere.com
- http://www.somewhere.com:8080
- https://www.somewhere.com
- https://www.somewhere.com:8080
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:
- AllowTcpForwarding yes
- GatewayPorts yes
Not sure what I am missing…
Best Answer
Quote from
man ssh