Troubleshooting: gcloud compute ssh could not fetch instance

Issues

On gcloud compute, I created an instance in project gvm. Then the command gcloud compute ssh failed to log into that instance. The error message is

1
2
3
4
5
$ gcloud compute ssh instance-1

$ ERROR: (gcloud.compute.ssh) Could not fetch instance:

- The resource 'projects/gvm/zones/us-west1-a/instances/instance-1' was not found

Troubleshooting

According to this Google Cloud Document. The reason for this case is the instance zone and gcloud default zone are different. The command line didn’t specified the instance zone. So the google cloud compute default zone was used. Obviously, The instance should not be found in the default zone. Just adding the zone option in command could solve the problem. The command format is like

1
gcloud compute --project "gvm" ssh --zone "instance-zone" "instance-name"

The cmd info could be fount in vm instances page in gcloud console.

  • find the instance
  • scroll the SSH list
  • choose View gcloud command

20190514_gcloud_ssh_cmd

This post is based on the original blog. The text and snapshot are updated.