【问题标题】:Can I use autossh for gcloud compute ssh?我可以将 autossh 用于 gcloud 计算 ssh 吗?
【发布时间】:2016-04-08 18:17:07
【问题描述】:

由于某种原因,ssh 无法设置通往我的 Google Compute Engine 实例的隧道。我必须使用gcloud compute ssh。我真的很想建立一个持久/弹性的隧道,就像autossh 一样。有什么办法可以使用gcloud compute ssh 做到这一点?

【问题讨论】:

    标签: ssh google-compute-engine gcloud autossh


    【解决方案1】:

    gcloud compute ssh 只需将您的 ssh 密钥复制到项目 sshKeys 元数据(请参阅 Cloud Console > Compute Engine > 元数据 > SSH 密钥)并使用 ~/.ssh/google_compute_engine 密钥运行独立 SSH。要查看调用的确切命令行,请运行 gcloud compute ssh --dry-run ...gcloud compute ssh 可以实现典型 SSH 的所有功能。

    另一个要调查的选项是gcloud compute config-ssh,它将您的~/.ssh/google_compute_engine SSH 密钥同步到项目并设置您的~/.ssh/config 文件,这样您就可以在没有gcloud 的情况下运行ssh

    【讨论】:

    • 请注意,gcloud compute config-ssh 仅适用于具有公共 IP 的实例,即对于我们这些依赖 IAP(身份识别代理)的人来说,它是不适用的。关于--dry-run - 它非常简洁,只需注意与 IAP 一起使用时,它输出的命令不能逐字使用,因为它在ProxyCommand 中缺少引号和“=”(至少从 gcloud 版本 283.0.0 开始)遇到这个,打印的语法是-o ProxyCommand /usr/bin/python3 -S ... -o ...,而应该是-o ProxyCommand="/usr/bin/python3 -S ..." -o ...
    猜你喜欢
    • 2019-12-20
    • 2015-07-11
    • 2023-03-13
    • 2020-08-29
    • 1970-01-01
    • 1970-01-01
    • 2015-11-15
    • 2019-02-13
    • 1970-01-01
    相关资源
    最近更新 更多