2
votes

I have created an instance on Google Compute Engine, but I can't seem to SSH using the terminal. The command that I used was :

gcloud compute ssh example-instance

The error that I got was:

ERROR: (gcloud.compute.ssh) Could not SSH to the instance.  It is possible that your SSH key has not propagated to the instance yet. Try running this command again.  If you still cannot connect, verify that the firewall and instance are set to accept ssh traffic.

When I googled the error, I was led to this link:Unable to SSH to Google Cloud

I went and checked the firewall rules here https://cloud.google.com/compute/docs/troubleshooting#ssherrors and things seem fine. I also went onto ~/.ssh and checked for google_compute_engine and google_compute_engine.pub which indicate the presence of my private and public key. I was wondering what I should do next? Is this is a problem specific to Mac workstations?

Any help would be really appreciated.

2
I'd recommend also going over the troubleshooting here. That's about SSHing from the browser but many of the reasons apply to gcloud compute ssh as well.Alexey Alexandrov

2 Answers

2
votes

Personally, had some trouble getting my ssh keys setup correctly by following the Google Cloud Engine docs. Found another logical solution...

This didn't take long and solved the problem (i.e., simple ssh access to Google Cloud VM via MacOS Terminal)...

Follow these simple instructions provided by nixCraft: https://www.cyberciti.biz/faq/google-cloud-compute-engin-ssh-into-an-instance-from-linux-unix-appleosx/

0
votes

Here are a few other things to check:

  • Can you ssh into that instance from a browser, using the "SSH" button in the Cloud Console?
  • If not, try a newly created instance using default settings and compare how your example-instance differs.
  • Run gcloud config list and confirm that the values for project, account, region, and zone match your expectations.