I am running a Compute Engine VM in Google Cloud.
When I set up the instance, I pasted a public key into the Security section. Now that the instance is running, I can see that public key on its page in Google Cloud console (so it was saved and is associated)
However, I cannot ssh
into the instance from my terminal. I opened Google's ssh client in the browser and saw that the ~/.ssh/authorized_keys
file does not have my public key in it.
I manually edited ~/.ssh/authorized_keys
to add a line with the same public key that is shown in the Google Cloud console on this instance, and found that I could connect from my terminal. But as soon as I terminate Google's in-browser ssh session, ~/.ssh/authorized_keys
is reset and public ssh connections are blocked.
How do I allow public ssh connections to this instance?
Permission denied (publickey).