We wanted to connect to a Google Cloud VM using a public key generated on the VM from a Mac Terminal. But we see the below error
konathal:.ssh konathal$ ssh -i ~/.ssh/runnhostkey1.pub suren@1.2.3.4
Load key "/Users/konathal/.ssh/runnhostkey1.pub": invalid format
suren@1.2.3.4: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
What we did?
Following the documentation at https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#createsshkeys
1.We created a new public key on Google Cloud VM as
~/.ssh/runnhostkey1
~/.ssh/runnhostkey1.pub
2.Added the public key runnhostkey1.pub
contents to VM > Edit > SSH Keys
3.Created a new file in local mac and copied the contents of the public key
$ vi ~/.ssh/runnhostkey1.pub
$ chmod 400 ~/.ssh/runnhostkey1.pub
We are not able to connect to the VM using $ ssh -i ~/.ssh/runnhostkey1.pub suren@1.2.3.4
What are we missing?