小编Mah*_*oud的帖子

如何使用 PyCharm 通过 IAP 隧道远程到虚拟机

我有一个没有分配外部 IP 地址的 google VM 实例。我打算通过本地计算机(运行 macOS)上安装的 PyCharm 建立 SSH 连接。

gcloud 这可以通过IAP 隧道在终端中完成:

gcloud compute ssh <instance_name> --tunnel-through-iap
Run Code Online (Sandbox Code Playgroud)

为实例添加的条目~./ssh/config如下:

Host compute.<instance_id>
  HostName compute.<instance_id>
  IdentityFile /Users/<user_name>/.ssh/google_compute_engine
  CheckHostIP no
  HostKeyAlias compute.<instance_id>
  IdentitiesOnly yes
  StrictHostKeyChecking yes
  UserKnownHostsFile /Users/<user_name>/.ssh/google_compute_known_hosts
  ProxyCommand /Users/<user_name>/miniconda3/bin/python3 -S /Users/<user_name>/google-cloud-sdk/lib/gcloud.py beta compute start-iap-tunnel <instance_name> %p --listen-on-stdin --project=<project_name> --zone=us-central1-a --verbosity=warning
  ProxyUseFdpass no
  User <user_name>
Run Code Online (Sandbox Code Playgroud)

借助 VS Code 的Remote-SSH 插件,可以直接使用此设置建立 SSH 连接,没有问题(示例)。

但是,我很难通过 PyCharm 设置连接。SSH配置选项卡包含:

 - Host: compute.<instance_id>
 - User name: compute.<instance_id>
 - …
Run Code Online (Sandbox Code Playgroud)

ssh pycharm google-cloud-platform

5
推荐指数
1
解决办法
1328
查看次数

标签 统计

google-cloud-platform ×1

pycharm ×1

ssh ×1