【问题标题】:SSH tunnel to a google cloud VM from windows and putty : Network error : connection timed out从 Windows 和 putty 到谷歌云虚拟机的 SSH 隧道:网络错误:连接超时
【发布时间】:2019-01-11 04:45:54
【问题描述】:

我正在尝试从 Windows 计算机连接到我的谷歌云虚拟机。

我的普通机器在 linux 下,这台机器一切正常,但现在我无法使用它,所以我尝试从这个 windows 的机器连接。

我安装了 gcloud sdk,当我尝试打开 ssh 隧道以连接到 Web UI 时:

gcloud compute ssh my-spark-master --project=my-project --zone=us-east1-b -- -D localhost:10000 -N

我遇到网络错误:连接超时

用户是在我的虚拟机上创建的(我在主目录中)。我的本地机器上有一个 google_compute_engine.ppk,我的项目上打开了 22 个 TCP 端口。我已经在我的 Windows 防火墙中授权了“C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\sdk\putty.exe”(但是做得好吗?)

 gcloud compute firewall-rules list
NAME                    NETWORK  DIRECTION  PRIORITY  ALLOW                         DENY
default-allow-icmp      default  INGRESS    65534     icmp
default-allow-internal  default  INGRESS    65534     tcp:0-65535,udp:0-65535,icmp
default-allow-rdp       default  INGRESS    65534     tcp:3389
default-allow-ssh       default  INGRESS    65534     tcp:22

To show all fields of the firewall, please show in JSON format: --format=json
To show all fields in table format, please see the examples in --help.

有什么提示吗?

【问题讨论】:

    标签: google-cloud-platform google-compute-engine ssh-tunnel


    【解决方案1】:

    使用 PuttyGen,创建一个 SSH 密钥(通过随机移动鼠标指针并保存 PPK 供以后使用)并将前缀为 ssh-rsa * 的文本添加到 Metadata -> SSH Keys in计算引擎服务。

    在 PuttyGen 中,Key-comment 提及您要用于登录 VM 的用户名,例如gcp 用户

    现在,当使用 Putty 连接到 Google Cloud Compute Engine VM 时,只需使用 gcp-user@<Public-IP-of-VM> 并在密钥对中使用上面保存的 PPK 文件。

    希望这对您有所帮助,如果有任何疑问,请告诉我。

    【讨论】:

    • 感谢您的回答,这让我用 putty 测试了一个简单的 ssh 连接。还行吧。我可以使用 putty 连接到我的 VM,但我无法创建访问 Web UI 所需的任何 ssh 隧道。谷歌命令是“gcloud compute ssh my_vm --project=my_project --zone=us-east1-b -- -D localhost:10000 -N”,我也试过 gcloud compute ssh user@my_vm --project=my_project -- zone=us-east1-b -- -D localhost:10000 -N with user = user i 用于正常的腻子连接
    • 对于 SSH 隧道,您必须在 Web 浏览器中做很多与代理相关的事情,然后必须创建 ssh 隧道。
    • 我终于设法直接从 putty 打开了一个 SSH 隧道(不使用 gcloud 命令)。我尝试使用以下命令启动 chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "my-vm:8123" --proxy-server="socks5://localhost:10000" --host-resolver-rules="MAP * 0.0.0.0 , EXLUDE localhost" --user-data-dir=/tmp/my-vm 在 linux 下工作,但仍然无法正确连接。更改整个系统配置不是我想要的,因为我仍然想使用其他浏览器正常连接到互联网...
    • 为了使其工作,有一些工具,如 foxyproxy 等,但这也很好。
    • 但它不起作用(使用 Windows)。我觉得我非常接近解决方案,但我找不到问题。有时间我会试试 foxyproxy(我今天下午回到 linux 机器上 :-))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 1970-01-01
    • 2012-03-08
    • 2019-06-21
    相关资源
    最近更新 更多