Unable to add public key for SSH

Issue #11143 resolved
will chen created an issue

I'm unable to add my public key to bitbucket via the website.

Steps to reproduce:

1 Went into ssh-keys
https://bitbucket.org/account/user/dead_eye/ssh-keys/
2 Click the add and the "Add SSH key" window pops up.
3 Copied key with "cat ~/.ssh/id_rsa.pub | pbcopy"
4 Named the key and pasted it into "Key*" and clicked the "Add key" button.

"Invalid SSH key." message appears and the following error appears in the javascript console:

POST https://bitbucket.org/!api/1.0/users/dead_eye/ssh-keys 400 (BAD REQUEST)
(index):5 nrWrapper
jquery.js:8434 send
jquery.js:7986 X.extend.ajax
bitbucket.js:199 (anonymous function)
bitbucket.js:865 i.user.t.add_ssh_key
ssh-keys.js:24 i.onCreate
form.js:46 l
aui-stable.js:5535 _onclick
jquery.js:3058 X.event.dispatch
jquery.js:2676 s.handle.a
(index):5 nrWrapper

Mac OSX 10.10.2
Chrome Version 41.0.2272.101 (64-bit) & Firefox 36.0.1

Comments (9)

  1. Jesse Yowell staff

    This issue tracker is for tracking known issues and feature requests on Bitbucket. Please e-mail this issue along with the ssh key and we'll see if we can reproduce
    Thanks,
    Jesse

  2. iowillhoit

    In case it will help someone in the future.. I was getting the "Invalid SSH key" message using PHP and CURL. Turns out when you pass an array to..

    curl_setopt($curl, CURLOPT_POSTFIELDS, $postValuesArray); 
    

    ...curl will automatically urlencode() those values. So make sure you're not encoding those values twice or BB will reject it.
    (Thanks to the Bitbucket team for helping me troubleshoot this)

  3. Log in to comment