谷歌云计算生成的 SSH 密钥如何查找 VPS 实例?

谷歌云计算生成的 SSH 密钥如何查找 VPS 实例?

如果我手动创建密钥,而不是使用 gcloud CLI 控制台,我还可以配置公钥,以便它像此配置一样查找连接:

thufir@mordor:~$ cat .ssh/config 
# Google Compute Engine Section
#
# The following has been auto-generated by "gcloud compute config-ssh"
# to make accessing your Google Compute Engine virtual machines easier.
#
# To remove this blob, run:
#
#   gcloud compute config-ssh --remove
#
# You can also manually remove this blob by deleting everything from
# here until the comment that contains the string "End of Google Compute
# Engine Section".
#
# You should not hand-edit this section, unless you are deleting it.
#
Host <instance>.<location>.<project>
    HostName <ip address>
    IdentityFile /home/thufir/.ssh/google_compute_engine
    UserKnownHostsFile=/home/thufir/.ssh/google_compute_known_hosts
    HostKeyAlias=compute.<####>
    IdentitiesOnly=yes
    CheckHostIP=no

# End of Google Compute Engine Section
thufir@mordor:~$ 
thufir@mordor:~$ ll .ssh
total 80
drwx------  2 thufir thufir  4096 Jul 28 04:00 ./
drwx------ 69 thufir thufir 36864 Jul 28 04:03 ../
-rw-------  1 thufir thufir   799 Jul 28 04:00 config
-rw-------  1 thufir thufir  1675 Jul 28 04:00 google_compute_engine
-rw-r--r--  1 thufir thufir   395 Jul 28 04:00 google_compute_engine.pub

特别是,HostName <ip address>线路是什么允许的ssh <instance>.<location>.<project>

查找是不是通过DNS建立?

请参阅类似的相关问题:

如何为 Google 云计算 VPS 附加带有 JSON 的 SSH 密钥?

答案1

特别是,HostName 行是什么允许ssh <instance>.<location>.<project>

是的。如果你的ssh配置HostName <ip address>一个特定Host somealias节的行,那么当您ssh somealias.


请注意,也可以为主机名指定 FQDN

Host abc
    HostName alpha.beta.nonexistent.com

在这种情况下,使用 DNS,但在 上HostName,而不是在Host别名上。但是,与您的设置无关。

相关内容