You can use the guide on Connecting to Linux Instances. The different options are(see link for details):
- Connecting using Compute Engine tools
- Connecting using third-party tools
- Connecting to instances that do not have external IP addresses
A very important issue with this last one, and the possible cause of your error is to set up the firewall rule, add a tag to it and then add this tag to your instance:
Note: Your Google Cloud Platform VPC network must have one or more firewall rules that allow SSH connections on port 22. The firewall
rules must allow SSH connections for the IP ranges or specific IP
addresses from which you want to connect.
See this doc about firewall rules and in step 8 of this codelab, you learn how to enable a rule. In you case your Destination protocol and port will be
tcp:22 and not
Before setting the rule, if I try to connect using this command:
gcloud compute ssh perezdesktop
I receive the same error message:
ssh: connect to host 00.111.222.333 port 22: Connection timed out
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code .
On the other hand, this error:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
has an answer here. Apparently:
.....someone else in your project set the per-instance metadata for
sshKeys (which overrides the project-wide metadata)....
See the link for details.