I need to do remote port forwarding that will listen 0.0.0.0
instead of 127.0.0.1
on the remote machine so that I can connect from outside internet to IP_OF_BBB:SOME_PORT
in order to connect to SSH port of AAA
.
I managed to make this happen by the following:
ssh -R 22:localhost:2222 user@BBB
ssh -L 2222:*:2223 user@localhost
Now I can connect to AAA
with this command:
ssh user@BBB -p 2223
The local port forwarding is a workaround, of course. Is there any clearer way to do this?
For remote port forwarding, enter the remote SSH server forwarding port in the Source Port field and in Destination enter the destination host and IP, for example, localhost:3000 . If setting up dynamic forwarding, enter only the local SOCKS port in the Source Port field.
There are three types of port forwarding with SSH: Local port forwarding: connections from the SSH client are forwarded via the SSH server, then to a destination server. Remote port forwarding: connections from the SSH server are forwarded via the SSH client, then to a destination server.
Enable GatewayPorts
in sshd_config (by default it is disabled). Enabling it will instruct sshd to allow remote port forwardings to bind to a non-loopback address. AskUbuntu has a similar question about Reverse Port Tunneling that goes into more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With