Error while adding SSH key with GitHub account it says Upload Failed
Asked by Divyesh Parmar:

Hello everyone I'm new to using SourceTree and I need to use the stash functionality basically for my task at work ( I know it can be done with git terminal as well )   

Whenever I set up my GitHub account and with SSH protocol and my SSH key it says   

\`\`\`  
Upload failed

There was a problem adding your new SSH key to your GitHub account. Please add this manually via their website.  
\`\`\`  

Now I have also again configured my system's Macbook pro's SSH key to my GitHub account again but the same error appears.   

Any help/information/guidance is appreciated.


Answers:
author: cilhao
body: The problem is that you have enabled your two factor authentication and Sourcetree is not able to connect. You must go to your GitHub account and create a Personal Access Token in Developer Settings, after that you go to you Sourcetree and edit the Auth Type of your GitHub account to Basic, fill your username and paste your newly created Access Token instead of your password, this will bypass the second factor of authentication.

comments: author: Sam Mojica
body: This worked like a charm. Thank you!


author: Bala Mithun
body: Thanks a lot. It worked now.


author: Manickam THANGARAJ -AWSINDIA-
body: thanks. works for me


author: mcolboc
body: this solution worked for me:

<https://community.atlassian.com/t5/Bitbucket-questions/SourceTree-can-t-detect-SSH-Keys-installed-on-OSX-any-more/qaq-p/54904>

1. Click the **Terminal** button
2. type

   ```
   ssh-add -K ~/.ssh/<git_key_name>
   ```

comments: author: Som Meaden
body: Can confirm this worked for me. New install using an old (sourcetree-generated) key.


author: chris warner
body: Hello, I am having this exact error with source tree 4.07.

I have tried all the recommended fixes and I cannot use source tree to access github at all.

I am running the latest install of Mac Catalina, and I have XCode setup to work with personal tokens from github, all access to github is managed through ssh keys per githubs recommendation as part of their security enhancements.

the only git client that doesn't work with github is now sourcetree.

Again, I have tried all the recommended fixes and I am still stuck with this error


author: Andrew Little
body: I am getting this error right now. I have source tree connected to a different GH account and everything works fine. I checked the .pub files are different and the config file is edited properly in my .ssh folder. not sure what else to do.

comments: author: Andrew Little
body: any ideas [@bgannin](/t5/user/viewprofilepage/user-id/744444) ? Even when i add the key manually it still wont load my remotes in from that GH project. Super odd


author: bgannin
body: When you run the command "ssh-add -l" does it show all your key(s) loaded into the agent?


author: Andrew Little
body: Hey [@bgannin](/t5/user/viewprofilepage/user-id/744444) - thanks for replying. Yeah all my keys are there


author: Daniel Birlem
body: I am also getting this error, but everything else related to Github integration seems to be working. Can't push or pull, basically can't do any work with Sourcetree and Github until this is fixed. Bummer!


author: takasurazeem
body: It was working fine, all my keys are loaded and Sourctree with GitHub has stopped working, same error!

comments: author: matt_wassell
body: Same issue for me.


author: bgannin
body: Hi Divyesh,

Our apologies for the hiccup. Can you check in Console for any logs from Sourcetree that are printed when this error occurs. Alternatively you can you follow the steps in [this article](https://community.atlassian.com/t5/Sourcetree-articles/Tip-from-the-team-debugging-Sourcetree/ba-p/794778) to help debug a bit further hopefully.

Brian Ganninger  
Senior Mac Developer, Sourcetree

comments: author: Divyesh Parmar
body: no there was no logs available in the console. And after few try and errors I was finally able to set it up with HTTPS and the software itself needs to get restarted before any repos gets loaded so yeah that way now its all set up and working.  

Thank you for the response. :)


author: Yair Hogri
body: I keep getting the same error, when I turned debugging on, this log keeps appearing:

2019-03-11 17:27:25 +0000 (e) Error uploading key. Server returned - {"message":"Not Found","documentation_url":"<https://developer.github.com/v3/users/keys/#create-a-public-key>"}


author: Nikishin Iliya
body: For me worked this:

1. I removed all my added SSH keys on github.com/settings/keys
2. Removed all credentials and access keys in Keychain Access on Mac OS
3. Reauthorized GitHub account in Source Tree Settings -\> Accounts

Yes, this is very brute force solution, but I was updated to a newly MacBook and didn't transfer data (including SSH keys) from old MacBook. So for me saving old SSH keys was optional.

**N.B.!** Do not use this solution if you are using your existing SSH keys on other machines.


Tags: github

mac

ssh