4
votes

We had a machine in google cloud which we connected to (via SSH) using our default project key.

The machine was up and working for a couple of days.
And now suddenly the server doesn't accept our key and we can't connect to it through the browser.

What can be done here? How can we regain access to our machine?

The VM is an Ubuntu Server 16.04.

1
Double check the IP address that you are connecting to. - John Hanley
Adding to @JohnHanley's comment. If you have shut down your instance, it is possible that your IP may have changed if you're using an ephemeral IP address on your instance. - hachemon
@hachemon I doubled checked the IP address. Also the SSH through the web interface doesn't work - Drxxd

1 Answers

0
votes

One thing I would review is the IP address, if your GCE instance is using ephemeral IP it may change if the instance is restarted.

Also, please try by accessing your GCE instance using gcloud command:

gcloud compute ssh INSTANCE_NAME --zone ZONE_NAME

If that doesn't work, force gcloud to recreate a new SSH key pair by moving the existing key pair:

mv ~/.ssh/google_compute_engine ~/.ssh/old-google_compute_engine
mv ~/.ssh/google_compute_engine.pub ~/.ssh/old-google_compute_engine.pub

After this, execute the gcloud compute ssh command and see if you are able to access.

If you are using a 3rd party client, try to generate a new SSH key file:

ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME] -C [USERNAME]

Then add the new SSH key to your GCE instance and try the connection again.