Permission denied (publickey) when attempting to SSH into GCP Cloud Shell

43 Views Asked by At

I followed this article to configure VS Code on my local machine to connect to my GCP Cloud Shell to edit code. It worked great.

A few hours later I needed to troubleshoot a Python issue so I restarted the Cloud Shell machine. Once Cloud Shell restarted, VS Code on my machine would not reconnect. I'm getting the permission denied error in the title.

I tried re-executing the gcloud cloud-shell ssh command on my machine, which creates a new pair of .ssh/google_compute_engine keys locally but those also failed to push to Cloud Shell. At this point I realized that by doing so, I've now created a key mismatch as the public key on my Cloud Shell instance no longer matches the keys on my local machine. I've tried this a few times and I fear I've now created a mess of keys of that don't match.

I want to stress that I can SSH into my VM instances in GCE. A lot of the troubleshooting I've read for this error states to create a new key in the Cloud Console | GCE | Metadata | SSH keys. But I haven't touched the id_rsa keys on my local machine, and its public key is still in the GCE Metadata. SSH access to Cloud Shell seems to use the google_compute_engine keys, which are not stored in the GCE Metadata as far as I can tell; it seems to only use the known_hosts file on my Cloud Shell instance.

Anyway....I'm stuck. Any help is appreciated.

0

There are 0 best solutions below