❯ gcloud compute ssh test-instance --project test-project --zone asia-northeast1-a WARNING: The public SSH key file for gcloud does not exist. WARNING: The private SSH key file for gcloud does not exist. WARNING: You do not have an SSH key for gcloud. WARNING: SSH keygen will be executed to generate a key. Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/hoge/.ssh/google_compute_engine. Your public key has been saved in /Users/hoge/.ssh/google_compute_engine.pub. The key fingerprint is: SHA256:PQXtls0bpoISsn+/u2vDpqMKBORO5VEFgEGqyJ4klcM hoge@MAC00011 The key's randomart image is: +---[RSA 2048]----+ |.+o+ooo. .. | |+oo.. .. | |ooE. ..+ | |*o .. . . .+ = | |++. o .S.o. o o | |+.. . . . ... . | | o. . . . . | | . . o = | | ...o.*** | +----[SHA256]-----+ Updating project ssh metadata...⠹Updated [https://www.googleapis.com/compute/v1/projects/test-project]. Updating project ssh metadata...done. Waiting for SSH key to propagate. Warning: Permanently added 'compute.3504985360589690116' (ECDSA) to the list of known hosts. Linux test-instance 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. hoge@test-instance:~$
# 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 test-instance.asia-northeast1-a.test-project HostName 35.200.9.109 IdentityFile /Users/hoge/.ssh/google_compute_engine UserKnownHostsFile=/Users/hoge/.ssh/google_compute_known_hosts HostKeyAlias=compute.3504985360589690116 IdentitiesOnly=yes CheckHostIP=no
# End of Google Compute Engine Section
あとは、使い慣れた sshコマンドでアクセスできますよ。
❯ ssh test-instance.asia-northeast1-a.test-project Last login: Sun Feb 16 11:58:05 2020 from 126.228.201.100 hoge@test-instance:~$