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

Issue #3052 resolved
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 (25)

  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. Former user Account Deleted

    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. Kjell Hedström

    Same problem here. Worked the other day on ubuntu, now I tried with windows 7, puttygen + ssh-2 rsa and I cant get it to work.

  4. 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.



  5. 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.

  6. Shaun Williams

    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.

  7. 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. :(

  8. 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.

  9. Arkadiusz Krakiewicz

    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!

  10. 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.

  11. Tim Osborn

    thanks for the suggestion @abhenderson - I had to prepend ssh-rsa, and delete the ---- BEGIN and end lines as well as the comment… I guess the develop who owned the key might be a putty user…

  12. JimJ

    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.

  13. Bryan Beecher

    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 :)

  14. James Legendre

    The issue still exists. It seems to be an unpredictable bug. What I did eventually was copy from the PuTTY Key Generator by using the mouse on Windows 10 and clicking to the left of the last character, dragging to highlight, then using mouse right click to copy and paste into BitBucket. This was after generating 3 or 4 keys and not succeeding in getting BitBucket to take the public key. It could be an interface issue in how the copy is being handled, but I just could not determine how what I did when it worked was any different.

    For what it's worth this is my second time to try BitBucket and I quit without ever using it the first time because of the exact same problem. Here's hoping the path is smoother now that it's working.

  15. Umesh

    i am in windows 10. Instead of default 1024 bit key, I generated 2048 bit key and then bitbucket accepted the public key. Workaround and also more secure.

  16. Doug Wolfe

    In case anyone stumbles on this old post. I had the same problem; turned out that when I selected the text for copy/paste, I was only selecting what was visible in the window. Turns out that there’s more if you scroll down. So be sure you’re selecting all the text.

  17. Log in to comment