Question: how gcloud compute ssh works?
Answer: gcloud compute ssh is a thin wrapper around the ssh(1) command that takes care of authentication and the translation of the instance name into an IP address. gcloud compute ssh ensures that the user's public SSH key is present in the project's metadata.