Issue #3052 resolved

Can't upload public key; it's rejected as "invalid" (BB-3096)

Alan Mackenzie
created an issue

I have attempted to upload my public key, (file attached). This is rejected as being an invalid key.

I have also tried copy/pasting it line by line into the little box for this purpose. This was likewise rejected.

Comments (21)

  1. Charles McLaughlin


    I haven't been able to replicate this bug report. I was able to upload and paste your public key into my local/development version of Bitbucket, which matches what we have on the production site. Not sure what to make of this.



  2. Anonymous

    i'm having the same issue. using windows 7 and have tried with chrome and firefox. public key is of type ssh-2 rsa, made with puttyGen.

  3. Dylan Etkin

    We have just rolled out an enhancement that lets you add labels to your SSH keys.

    As part of this effort and in an attempt to simplify the workflow we have removed file upload for ssh keys. Instead we OS detect and provide a command that will help you put the key into your clipboard.



  4. Nathan Finch

    This is still happening to me. I even tried switching from CRLF to LF line endings just to see if that mattered. It didn't. My key is also ssh-2 RSA generated from puttygen.

  5. shaunew

    Nathan, make sure to paste what's in the textbox in PuTTYgen titled "Public key for pasting into OpenSSH authorized_keys file". Don't paste the contents of the private key file. They differ.

  6. Argand

    IMPORTANT: be sure to read the comment from shaunew, I just ran into this problem myself because I was pasting the contents of my public key file created via the "Save public key" feature. That button/file menu item, will generate a PEM format public key, whereas the textarea at the top of PuttyGen titled "Public key for pasting into OpenSSH authorized_keys file:" is the OpenSSH formatted version of your public key file, the version that Bitbucket requires.

    It's a little bass ackwards considering by default ssh-keygen produces an OpenSSH format and requires a conversion command switch to generate the PEM format. But that's the skinny - for more info:

    That's the limit of my knowledge regarding ssh keys, so if you try this and still can't get it to work, sorry. :(

  7. Chris Lyon

    The documentation is correct but doesn't really cover user experience very well. If you have an existing private key on your system then you can Load it into PuTTYGen and it will display the key in the correct format in the Public key for pasting into OpenSSH authorized_keys file: section.

    This can be copied and pasted into the BitBucket add key dialog text box. ( Well it works for me, after much mucking around) It seems the application is a bit fussy about the sorts of headers & tailers that get added as a matter of course to these files.

  8. oscdeveloperpl

    It's worked for me, but ONLY when I choosed in Putty Key Generator:

    SSH-2 RSA

    1024 bits

    and copy public key from puttyGen window "OpenSSH authorized_keys", well NOT FROM SAVED FILE with public key!

  9. Alex Henderson

    This worked for me. The (SSH-2 RSA, 2048 bit) puttygen public key file looks like this...

    ---- BEGIN SSH2 PUBLIC KEY ---- Comment: "rsa-key-20140416" AAAAB3NzaC1yc2EAAAABJQAAAQEAu+qEadidPTkxW5dydJj0466fbSCzBnN+J1Lq ...<snip>... 6HPxeGQHm3xl7hx1ADiEFAwTrPKHy3hWR4nvyl7DUZaHNwUkGQ== ---- END SSH2 PUBLIC KEY ----

    Prepend 'ssh-rsa ' (that's a space after the 'a') to the second line and copy these lines to Bitbucket

    ssh-rsa AAAB3NzaC1yc2EAAAABJQAAAQEAu+qEadidPTkxW5dydJj0466fbSCzBnN+J1Lq ...<snip>... 6HPxeGQHm3xl7hx1ADiEFAwTrPKHy3hWR4nvyl7DUZaHNwUkGQ==

    You can also move the comment to the end (after the '==')

    When saving a puttygen public file the output has Unix line endings on Windows.

    It would be helpful for Atlassian to automatically parse these keys generated by putty since they're the main source of SSH keys from Windows users.

  10. Jim Willeke

    Guess I will move to another repository. Spent an hour trying to put in keys with no success. Appears there is no effort to fix this ongoing problem.

  11. brybeecher

    Had this issue. Was copying the key from the generated file from clicking the "Save public key" button. Copying directly from the PuTTY Key Generator textarea labelled with the text "Public key for pasting into OpenSSH authorized_keys file:". Guess it makes sense :)

  12. Log in to comment