Ubuntu – New SSH Connection failed Google Cloud VM

google-cloud-platformgoogle-compute-engineUbuntuubuntu-16.04

I recently formatted my system, I thought better to create new SSH for login into the system from the Local system.

Steps I followed :

  1. Remove all previous keys to VM leaving one Key, which is user_name.
  2. Tried connecting to In Browser SSH it started failing, I tried rebooting VM Nothing works.
    3.Then copied previously all SSH keys from backups into my local system just to make connection and working side by not affecting my development.
    4.Added new SSH Keys in VM Instance Project Wide SSH keys, tried logging into VM Instance from the local system, Successfully.
  3. Tried with google-cloud SDK using previous key Successful.
  4. But Browser SSH is still failing.
  5. ~/ssh/authroized_keys there are keys which I added for automatic deployment.

Problems which I detected :
1. After the following troubleshooting from google, when I tried login using fresh user it's failed.

gcloud compute ssh test@vh-server
Updating project ssh metadata.../Updated [https://www.googleapis.com/compute/v1/projects/project-name].
Updating project ssh metadata...done.                                                    
Waiting for SSH key to propagate.
Permission denied (public key).
ERROR: (gcloud.compute.ssh) Could not SSH into 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.
  1. New SSH login using new public and a private key is also failing. I created new keys, updated SSH keys in VM instance.

    ssh -i ~/.ssh/my-ssh-key test@ip_address
    ssh: connect to host ip_address port 22: Operation timed out

  2. No In Browser SSH Login.

I followed this question no help Not able to browser login

Any Help would be appreciated

Problem : –

I am not able to do in browser SSH Connection

Best Answer

Finally, this resolved my problem: I am able to log in from the browser and new keys

If you're seeing this on Debian 8 or 9, the most likely reason for this is that the google-compute-engine.* packages that allow SSH access to the instance has been removed by apt-get autoremove.

If you have an open SSH connection to the machine or can use a tool like gcloud, running apt-get update && sudo apt-get install gce-compute-image-packages should fix this.

If you no longer have any SSH access, there is a procedure available on the GCP docs site that can be used to restore it.

For more : https://stackoverflow.com/a/48257469/637377.