Connect to SSH forwarded port from a different host

openssh, port, portforwarding, ssh

Solution

For security reasons, `ssh` only allows the local host to connect to a forwarding/forwarded port by default. With OpenSSH, see the `GatewayPorts` directive — but consider that this restriction exists for a reason.

You probably want to establish a forwarding between A and B as well as the one from B to C, such that connecting to the forwarded port on A creates a connection to the forwarded port on B, leading to C.

Problem

I've three hosts A, B and C. B is reachable from both A & C. From C I establish an SSH connection to B while also forwarding a port on B to one on C. Now on B I can successfully connect to this local port that has been forward to one on C. But when I try to connect to that port on B from A (hoping to reach C from A), the connection fails. What might be causing this ? A & B are running cygwin on Win7 x64. C is running RHEL5. I've ruled out the possibility of this being a firewall issue by turning off the firewalls on all hosts.

Original source