SSH Remote Port Forwarding Specify Interface
Asked Answered
L

1

9

I use this for remote port forwarding over SSH tunnel:

ssh [email protected] -R 443:127.0.0.1:443

this binds to 0.0.0.0:443 and forwards to 127.0.0.1:443 .

The remote server has multiple IPs. Is it possible to specify the IP I want to bind to, for instance 10.10.10.1:443, instead of binding to all interfaces?

iptables is not available on the remote server.

Locket answered 18/1, 2015 at 16:50 Comment(1)
The SSH man page says: -R [bind_address:]port:host:hostport but it doesn't work. It ignores the bind_address and binds to all interfaces :(Locket
L
17

I managed to solve it.

On the remote server I set in sshd_config:

GatewayPorts clientspecified

Then I changed the arguments on the client like this:

ssh [email protected] -R 10.10.10.1:443:127.0.0.1:443

Now it works as expected, SSH binds to port 443 on interface 10.10.10.1 and forwards all traffic over the tunnel to localhost:443 .

Locket answered 19/1, 2015 at 1:59 Comment(1)
This is helping me 7 years later :)Shaffer

© 2022 - 2024 — McMap. All rights reserved.