0

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...

1 Answer 1

0

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

2
  • Thanks, this was already enabled in sshd_config. Updated the question to reflect this. Commented Jan 2, 2022 at 13:25
  • I checked my sshd_config again and between restoring VM's and stuff, looks like I forgot to redo this step. Commented Jan 2, 2022 at 14:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.