I have two CentOS 7 servers (Hypervisor and Relay for this scenario) . I wish to connect to a VNC port on Hypervisor which is behind a firewall by using Relay with is a server with SSH open to Hypervisor.
I ask Hypervisor to establish the connection with the command:
ssh -N -R 0.0.0.0:5912:127.0.0.1:5912 root@Relay
Once I do this, I can connect to the port on Relay by
telnet localhost:5912
and I receive the response: RFB 003.008
When I telnet using the assigned IP address:
telnet 1.2.3.4:5912
on Relay: Connection Refused
Note, the IP 1.2.3.4 is the IP of Relay's NIC, and not some NAT'd IP.
I can not connect from another server within Relay's subnet either.
By default sshd refuses to allow remote access to ports forwarded in this manner. This is documented in the
ssh(1)
man page.The documentation for
GatewayPorts
says that it is off by default. As it is security-sensitive, this is a reasonable default. Fromsshd_config(5)
: