命令 "gcloud compute ssh" 和 "ssh" 之间的区别

Difference between the commands "gcloud compute ssh" and "ssh"

gcloud compute ssh命令和"just"ssh命令究竟有什么区别?

我观察到即使这样我也可以使用 gcloud compute ssh 轻松连接两个实例,但我无法使用 ssh 命令做到这一点。但是,在手动设置 ssh-keys 之后,ssh 命令可以正常工作。但是 gcloud 命令不应该处理密钥管理吗?而且如果是用gcloud设置一次,为什么ssh命令不能正常工作

.

工作正常:

gcloud compute ssh instance_2
gcloud compute shh instance_1

.

如果不手动设置 ssh-keys 就无法工作:

ssh instance_2
shh instance_1

.

这个问题来自我遇到的另一个问题,这让我抓狂了好几天:

gcloud compute ssh 将密钥对安装为 ~/.ssh/google_compute_engine[.pub]。 ssh 默认使用 ~/.ssh/identity[.pub].

您可以将 google 密钥对复制到默认名称:

$ cp ~/.ssh/google_compute_engine ~/.ssh/identity
$ cp ~/.ssh/google_compute_engine.pub ~/.ssh/identity.pub

或者您可以只指定调用 ssh 时要使用的私钥:

$ ssh -i ~/.ssh/google_compute_engine instance_name

专用 google 命令 gcloud compute ssh instance 基本上在底层使用标准 ssh,但在顶部做了一些魔术,例如安装钥匙。在这个问题的答案中有很好的解释: How to get the ssh keys for a new Google Compute Engine instance?