Score:0

OpenSSH on Windows always binds sockets used for Remote Forwarding to LOOPBACK

id flag

Like the title says.

Host A acts as a server (bastion-host, call it whatever you will).

Now, host B performs:

ssh -R 2222:localhost:22 user@A

as a result a TCP socket gets spawned at A, but it is bound to 2222@Loopback i.e. preventing remote connections to it.

How to change 127.0.0.1 to 0.0.0.0 or anything else more sensible?

id flag
Think I Got it: GatewayPorts set to yes in SSH config.
Score:2
my flag

You're missing the optional bind_address part of the -R specification. In the ssh documentation (as linked by Microsoft) it writes,

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. Specifying a remote bind_address will only succeed if the server's GatewayPorts option is enabled (see sshd_config(5)).

You're using the three-tuple version of the parameter, but you need the four-tuple version:

-R port:host:hostport
-R [bind_address]:port:host:hostport

So, to allow anyone to connect to the listening port on the remote server, you need to ensure that GatewayPorts is enabled in the server's sshd_config and use a command variation like this:

ssh -R :2222:localhost:22 user@A

The leading colon (:) also implies a leading asterisk wildcard that allows connections from anywhere. Personally I think this version with the wildcard makes it clearer that what is written is intentional:

ssh -R *:2222:localhost:22 user@A
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.