
Answer-first summary for fast verification
Answer: Simply use the gcloud compute ssh command to connect.
The most efficient method is to use the `gcloud compute ssh` command. This command automatically handles the generation of an SSH key (if none exists) and ensures the key is added to the project's metadata, streamlining the connection process. It also enhances security by storing host keys as guest attributes, protecting against potential man-in-the-middle attacks. Other methods require additional manual steps, such as generating and uploading keys separately, making them less efficient. For more details, refer to Google Cloud's documentation on connecting to instances and managing SSH keys.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You need to SSH into one of your Compute Engine instances in an unmanaged instances group to run an ad hoc script. You've authenticated with gcloud but haven't deployed an SSH key yet. What's the quickest method to establish an SSH connection?
A
Generate a key using ssh-keygen, upload it to the instance, retrieve the instance's IP with gcloud compute instances list, and then SSH into it.
B
Simply use the gcloud compute ssh command to connect.
C
Retrieve the instance's IP with gcloud compute instances list and SSH into it directly.
D
Generate a key with ssh-keygen and then use the gcloud compute ssh command to connect.