首页 > 解决方案 > 到虚拟机的 IAP 隧道

问题描述

我有一个关于 Compute VM 及其相关权限的问题。我在项目级别拥有“所有者”权限。我创建了一个 VM,但无法为其分配外部 IP 地址。参考谷歌云文档后,看来我仍然可以使用 VPN 或 IAP 连接到此 VM。单击 VM 旁边的 SSH 链接后,我看到它使用 Cloud-IAP 隧道,但连接失败。

这是错误消息 External IP address was not found; 默认使用 IAP 隧道。

ERROR: (gcloud.compute.start-iap-tunnel) Error while connecting [4003: u'failed to connect to backend'].
ssh_exchange_identification: Connection closed by remote host
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].

我该如何连接到这个虚拟机?

感谢您对此的帮助

标签: google-compute-enginegoogle-iap

解决方案


防火墙规则配置为允许从您计算机的所有端口上的 Cloud IAP 的 TCP 转发网络块 35.235.240.0/20 进行访问。这可确保允许从 Cloud IAP 的 TCP 转发 IP 地址到资源上管理服务的 TCP 端口的连接。请注意,如果将 default-allow-ssh 和 default-allow-rdp 默认规则应用于用于 SSH 和 RDP 的端口,您可能不需要调整防火墙规则。

可能您已经拥有default-allow-ssh而不是尝试:

gcloud compute start-iap-tunnel stage-es-kibana 5601 --local-host-port=localhost:5601

通过额外的 ssh 层跳转到端口:

gcloud compute ssh stage-es-kibana -- -N -L 5601:localhost:5601

stage-es-kibana:5601或在 host/port和 subnet之间打开 Google Firewall 35.235.240.0/20


推荐阅读