[英]gcloud compute ssh from one VM to another VM on Google Cloud
我正在尝试使用gcloud compute ssh
命令从 Google Cloud 中的另一个 VM ssh 到 VM。 它失败并显示以下消息:
/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/compute/lib/base_classes.py:9: DeprecationWarning: the sets module is deprecated
import sets
Connection timed out
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. See https://cloud.google.com/compute/docs/troubleshooting#ssherrors for troubleshooting hints.
我确保 ssh 密钥已到位,但仍然无法正常工作。 我在这里缺少什么?
假设您已事先通过 gcloud 使用 SSH 连接到外部可见的实例。
在您的本地机器上,使用以下命令启动 ssh-agent 来管理您的密钥:
me@local:~$ eval `ssh-agent`
调用 ssh-add 将 gcloud 计算公钥从本地计算机加载到代理中,并将它们用于所有 SSH 命令以进行身份验证:
me@local:~$ ssh-add ~/.ssh/google_compute_engine
使用外部 IP 地址登录实例,同时提供 -A 参数以启用身份验证代理转发。
gcloud compute ssh --ssh-flag="-A" INSTANCE
来源: https : //cloud.google.com/compute/docs/instances/connecting-to-instance#sshbetweeninstances 。
我不确定“标志”,因为它对我不起作用,但也许我有不同的操作系统或 Gcloud 版本,它对你有用。
以下是我在 Mac 上运行以连接到 Google Dataproc 主虚拟机,然后从主 MV 跳转到工作虚拟机的步骤。 我通过 ssh 连接到主 VM 以获取 IP。
$ gcloud compute ssh cluster-for-cameron-m Warning: Permanently added '104.197.45.35' (ECDSA) to the list of known hosts.
然后我exit
ed。 我为该主机启用了转发。
$ nano ~/.ssh/config
Host 104.197.45.35 ForwardAgent yes
我添加了 gcloud 密钥。 $ ssh-add ~/.ssh/google_compute_engine
然后我通过使用ssh-add -l
列出密钥指纹来验证它是否已添加。 我重新连接到主 VM 并再次运行ssh-add -l
以验证密钥确实已转发。 之后,连接到工作节点工作得很好。
ssh cluster-for-cameron-w-0
关于使用 SSH 代理转发...
由于实例在云上频繁创建和销毁,(重新创建的)主机指纹不断变化。 如果新指纹与~/.ssh/known_hosts
不匹配,SSH 会自动禁用代理转发。 解决办法是:
$ ssh -A -o UserKnownHostsFile=/dev/null ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.