Cannot connect to GitHub with 2FA / SSH using SourceTree 3.0

jsaelhof
Contributor
December 18, 2018

I'm trying to setup sourcetree 3 on a new Mac. I already had my SSH key created and added to GitHub prior to installing SourceTree. When i go into the accounts section in sourcetree and try to add my GitHub account with SSH, I get a message during the "connect" phase that says "There was a problem adding your new SSH key to your GitHub account". GitHub doesn't allow adding the same key twice so i tried removing it on their end but it still didn't help. I get the same message. Obviously source tree won't let me pull because of credentials errors. This was really easy with Personal Access tokens in SourceTree 2...what can I try in SourceTree 3 to get this to connect?

Thanks

2 answers

2 votes
Manju
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 18, 2018

You can login to GitHub on Sourcetree using OAuth and post that use either your own ssh key or a new ssh key generated from Sourcetree. If this key isn't already present on the host, it will be uploaded to GitHub by Sourcetree. 

Lastly, Please check if the ssh-agent has your keys loaded. If not, please add them to the agent. 

Run below commands in terminal to do so,

To check if keys are loaded:

ssh-add -l

To add keys to agent:

ssh-add <path_to_key>

more like,

ssh-add ~/.ssh/id_rsa

Key in the passphrase used while generating the ssh key and you should be good to go.

jsaelhof
Contributor
December 18, 2018

Thanks Manjunath,

For some reason my ssh key was not added to the agent. I thought this had been done. I added it successfully but it still doesnt fix the issue. I get authentication errors if a try to pull from my remote repo and if i go into the accounts panel and connect with github using my id_rsa.pub I get the same error saying "There was a problem adding your new SSH key to your GitHub account". I assume the error with adding the new key is because the key already exists on GitHub but if i delete the SSH key on GitHub, SourceTree still reports that there is an error adding it. So i do what it says and add it manually but still get nothing.

Like # people like this
jsaelhof
Contributor
December 18, 2018

For the record, having SourceTree generate a key gives the same error about being unable to add it to github.

Like Peter Campbell likes this
Kathy Jacob
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 9, 2019

Hi Jason,

I am also facing same issue as yours.

Did you get any solution to this problem?

0 votes
Russell Warwick
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 20, 2021

Make sure the origin is not using https and its just git@github SSH option. Had the same issue and at some point it made a weird switch.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events