Cannot upload public SSH key generated by puttygen on Windows

Asked by JianminX on 2008-03-10

Platform: Windows XP SP2
puttygen version: 0.54
pageant version: 0.54

I tried several times with different key type but alway failed to import. my last public key follows.
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20080310-bzr-launchpad.net"
AAAAB3NzaC1yc2EAAAABJQAAAIEAvqA2RtZyOq17uj/xUcQJS81BFugXYCsVx/Jk
3Zl45f59sJsbB8JFzZ7xCFsCZmv4fg8YWCGEIXun1KTNyE45NZwtUysFa1QyySrm
UWis7P5Qei7GkAknKi+MA4cafRFMJ1WA1jo54Pzjrde5HHnxr27ErFInDv7idGIt
HN0XwN0=
---- END SSH2 PUBLIC KEY ----

Please advise.

Question information

Language:
English Edit question
Status:
Answered
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Last query:
2008-03-10
Last reply:
2009-06-04
JianminX (heidan) said : #1

Every time I tried to import, I got 'Invalid public key'.

Open the key with a text editor an copy all the content. Try to paste it on the launchpad import page, instead of pointing to the file on your computer.

Diogo Matsubara (matsubara) said : #3

Hello Jianmin,

instead of using the contents of the saved key, use the contents of "Public key for pasting into OpenSSH authorized_keys file:" of the Putty Key Generator application.
It should look like:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAvqA2RtZyOq17uj/xUcQJS81BFugXYCsVx/Jk3Zl45f59sJsbB8JFzZ7xCFsCZmv4fg8YWCGEIXun1KTNyE45NZwtUysFa1QyySrm
UWis7P5Qei7GkAknKi+MA4cafRFMJ1WA1jo54Pzjrde5HHnxr27ErFInDv7idGItHN0XwN0= rsa-key-20080310-bzr-launchpad.net

Diogo Matsubara (matsubara) said : #4

No new line character:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAvqA2RtZyOq17uj/xUcQJS81BFugXYCsVx/Jk3Zl45f59sJsbB8JFzZ7xCFsCZmv4fg8YWCGEIXun1KTNyE45NZwtUysFa1QyySrmUWis7P5Qei7GkAknKi+MA4cafRFMJ1WA1jo54Pzjrde5HHnxr27ErFInDv7idGItHN0XwN0= rsa-key-20080310-bzr-launchpad.net

Dave Anderson (davious) said : #5

I had the same woes you did.
Puttygen displays a text box with the cut and paste version of the key.
First I saved the public key, then opened it up and tried cutting and pasting without luck.
Then I noticed Puttygen's textbox and bingo.

kayatsu (kayatsu) said : #6

what you need to do, copy paste from the text box that puttygen provide not viewing file from the generated public key files.

lborgman (lennart-borgman) said : #7

I have added a note about this on [[CreatingAnSSHKeyPair]]

Could someone perhaps correct the link there to this page. I have no idea how to make it prettier.

But it would of course be much better if Launchpad understood the format stored in the file too.

Murat Bi┼čkin (muratbiskin) said : #8

I had this problem also and i copy paste all the text from where it say's
Public key for pasting into OpenSSH authorized_keys file

Rudy Lattae (rudylattae) said : #9

Here's my 5 pesos worth... (psst! you may realize that this is pretty much what folks like Diogo have been saying up there :)

Easy way out (this was mentioned earlier):
- Go through the process of generating a key with Puttygen.
- Save your keys (public and private) But don't close the Puttygen window just yet!
- Copy the public key from the Puttygen window. This way you get key, the whole key and nothing but the key.

OR (if you went ahead and generated the files then closed Puttygen -- like I did):

Here is an example of a generated public key (note -- it's not real):

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20080829"
alp1hanuQSmericgib21berisDShalphanume1ricgibberish2salpdffZXhanumericgibberish
ericgib21berisDShalphanume1ricgibberish2salpdffZXhanumericgibberish
alp1hanuQSmeric25SF6gib21berisDShalpAHJ34Khanume1ricg
bKY2PQ==
---- END SSH2 PUBLIC KEY ----

Basically the actual key is the gibberish after the "Comment" line and before the "---- END..." line.
So you would have to copy your key from "alp1hanuQSmericgib21..." all the way to "==".
Then you should prefix the whole thing with "ssh-rsa " -- note the space after the "a".
And finally you should tack on the entry in comment (in this case "rsa-key-20080829") without the quotes ("") at the end of the key. Again separate it from the main key with a space.

You must make sure the whole thing is on one line. So in this case you would have:

ssh-rsa alp1hanuQSmericgib21berisDShalphanume1ricgibberish2salpdffZXhanumericgibberishericgib21berisDShalphanume1ricgibberish2salpdffZXhanumericgibberishalp1hanuQSmeric25SF6gib21berisDShalpAHJ34Khanume1ricgbKY2PQ== rsa-key-20080829

It probably looks like it's on more than one line (the text is being wrapped) but it's definitely all on one line.

So taking this back to Jianmin's original question, you would end up with (again ignore any virtual wrapping -- the whole thing is on one line):

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAvqA2RtZyOq17uj/xUcQJS81BFugXYCsVx/Jk3Zl45f59sJsbB8JFzZ7xCFsCZmv4fg8YWCGEIXun1KTNyE45NZwtUysFa1QyySrmUWis7P5Qei7GkAknKi+MA4cafRFMJ1WA1jo54Pzjrde5HHnxr27ErFInDv7idGItHN0XwN0= rsa-key-20080310-bzr-launchpad.net

Hope this helps someone.

Cheers

Rodin Shih (schludern) said : #10

Yeah, I use puttygen load my private key again and saw the write form of a DSA ssh2 key, after copy to lp and submit, import successful finally...

The prefix of a DSA key is "ssh-dss" not "ssh-dsa" :'( , the other parts is same with rsa example of Rudy Lattae's.

Hope this will be useful for some guys used ssh2 dsa like me ...

Giorgio Wicklein (giowck) said : #11

Thanks Rudy Lattae! It works!!

Thanks Ruddy! Works fine to me!

Thanks Rudy, it helped me! For some reason after creating the public key (in Xubuntu Jaunty) after the "==" said: user@hostname and it told me "Invalid Public Key". It looks like the system don't accept characters such "@" for the comment, I changed it and then it worked :).

Anthony Dillon (ya-bo-ng) said : #14

Thanks Rudy, worked great for me! Seem's to me the help page should be updated to tell Windows users to prefix the key from PuTTY Key Gen with "ssh-rsa " as you said. Also end it with the nickname of the machine.

Thanks again!

Can you help with this problem?

Provide an answer of your own, or ask JianminX for more information if necessary.

To post a message you must log in.