2

If I manually create a key, rather than using the gcloud CLI console, can I also configure the public key so that it will look-up the connection as this config seemingly does:

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

In particular, the HostName <ip address> line is what allows ssh <instance>.<location>.<project>?

The lookup is not established through DNS?

see sort-of related question:

How do I append a SSH key with JSON for Google cloud compute VPS?

1
  • 1
    Yes. But it might be possible to go through the DNS. You can verify that using dfig <instance>.<location>.<project> – Jakuje Jul 28 '16 at 12:21
2

In particular, the HostName line is what allows ssh <instance>.<location>.<project>?

Yes. If your ssh config has a HostName <ip address> line for a particular Host somealias stanza, then DNS is not used when you ssh somealias.


Note that it is also possible to specify a FQDN for the HostName

Host abc
    HostName alpha.beta.nonexistent.com

in which case DNS is used, but on the HostName, not on the Host alias. However, not relevant to your setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.