Search code examples
sshputtygoogle-compute-enginepublic-keygoogle-cloud-platform

Need proper syntax for using public key generated by PuTTYgen in GCE


I am trying to connect to Google VM via PuTTY and can't seem to add the public key properly.

I have followed instructions on as per:
https://cloud.google.com/compute/docs/console#sshkeys

However, I seem to have pasted the key incorrectly.

My PuTTY key is generated as

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20141121"
AAAAB3NzaC1yc2EAAAABJQAAAQEAklz2lupNnZFPXTRivb8ba4JB90YLc7qZh05d
OcFq9WqRuUNTu2f0fgC49FEEx9aCCWOrGZS/CWpoKmHd1Q4pEfHFJ/EOWB1ZOpNh
LnIT/HZT6aOLBXZg3aoyrL9BXyh3eWnUA8qOZDa/Jl4vt1alPO6XsYzfl7YUs+m7
GcUnTgvwxn+beCXuLZbDlVP/tco6UKSx4Rj0uVkwdsgstCs2b0lnx2o+vabVI+28
WHqsORahZMdSL8yXiFJ+pPye8wkolmicvfVJU0mqflhsmC0w2TJ4AGnkHOG9OjwJ
EaekMA89w7Of9W/WXE94zAj8LeYn2LMEYkKQHu+EJ902gfaLiw==
---- END SSH2 PUBLIC KEY ----

Can anyone post the key in the correct format as per the link I have mentioned above:

protocol publickey username

I am not clear which is which in this case e.g should I include the quotes in rsa-key as well as the number 20141121 ?

I am messing up on the syntax so details would be appreciated as I am already able to SSH using Google Clouds tools and also able to connect using PuTTY but fail at authentication.


Solution

  • For details, see (my) guide Connecting Securely to Google Compute Engine Server with SFTP with WinSCP.

    Example (not your key):

    PuTTYgen

    I.e. the format you need to paste to the authorized_keys file is very different to the format, you see when you open the key file in a text editor.

    Also the format you have included in your message is not the PuTTY key format, it's the ssh.com format. Which is completely irrelevant to your setup (PuTTY client and OpenSSH server).