У меня есть два сервера CentOS 7 (гипервизор и Relay для этого сценария). Я хочу подключиться к порту VNC на гипервизоре, который находится за брандмауэром, с помощью Relay с сервером с SSH, открытым для гипервизора.
Я прошу гипервизор установить соединение с помощью команды:
ssh -N -R 0.0.0.0:5912:127.0.0.1:5912 root@Relay
Как только я это сделаю, я могу подключиться к порту на Relay с помощью
telnet localhost:5912
и получаю ответ: RFB 003.008
Когда я использую telnet, используя назначенный IP-адрес:
telnet 1.2.3.4:5912
на ретрансляторе: в соединении отказано
Обратите внимание, что IP 1.2.3.4 - это IP-адрес сетевой карты Relay, а не какой-то IP-адрес с NAT.
Я не могу подключиться с другого сервера в подсети Relay либо
По умолчанию sshd отказывается разрешать удаленный доступ к портам, переадресованным таким образом. Это описано в руководстве ssh(1)
.
Specifying a remote bind_address will only succeed if the
server's GatewayPorts option is enabled (see sshd_config(5)).
В документации к GatewayPorts
сказано, что по умолчанию он выключен. Так как он чувствителен к безопасности, то это разумное значение по умолчанию. Из sshd_config(5)
:
GatewayPorts
Specifies whether remote hosts are allowed to connect to ports
forwarded for the client. By default, sshd(8) binds remote port
forwardings to the loopback address. This prevents other remote
hosts from connecting to forwarded ports. GatewayPorts can be
used to specify that sshd should allow remote port forwardings to
bind to non-loopback addresses, thus allowing other hosts to con‐
nect. The argument may be no to force remote port forwardings to
be available to the local host only, yes to force remote port
forwardings to bind to the wildcard address, or clientspecified
to allow the client to select the address to which the forwarding
is bound. The default is no.