Mah*_*oud 5 ssh pycharm google-cloud-platform
我有一个没有分配外部 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>
- Port: 22
- Authentication type: key pair
- Private key file: path to ~/.ssh/google_compute_engine
Run Code Online (Sandbox Code Playgroud)
并因主机格式不正确而引发异常。如果我尝试使用虚拟机实例的内部 IP 地址作为主机,连接会超时。
是否有类似于Remote-SSH
VS Code for PyCharm 中的插件可以与 IAP 隧道一起正常工作?或者可以通过任何其他方式设置而不向虚拟机实例公开或分配外部 IP?
小智 0
我知道已经有一段时间了,但我只是在做同样的事情。我在 ~./ssh/config 中使用了相同的配置条目,但 PyCharm 正在执行一些检查以确保顶级主机值有效(即使它没有被使用)。我用可以通过验证检查的东西替换了它,但我知道我永远不会真正使用(以避免潜在的冲突)。
例如,您可以更新为:
Host mahmoud.local
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)
然后,当您在 PyCharm 中配置 SSH 连接时,您将需要使用 Host = mahmoud.local
归档时间: |
|
查看次数: |
1328 次 |
最近记录: |