Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Having Trouble Creating SSH Key And Connecting To GitHub On Mac Edited

djooryab I'm New Here Dec 27, 2020

Hello, 

I've been struggling to create an SSH key in SourceTree on Mac, and have it successfully connect to my GitHub repo. I try to add my account and click on the "Generate SSH Key" option, and that works fine. But, then it gives me an error saying that the SSH key failed to upload to GitHub and that I should manually add the SSH Key. Ok... So I do that and copy and paste the public key from Sourcetree into GitHub, but then, when I try to clone my repo, I get infinitely stuck on the spinning wheel while my remote is loading. How can I set up SSH keys with Sourcetree and Github on Mac?

2 answers

1 accepted

1 vote
Answer accepted
djooryab I'm New Here Dec 27, 2020

Hello everybody, 

I have great news. I found a good solution to this problem which I will outline for everybody below. This solution works for authenticating using SSH AND 2-Factor Authentication for SourceTree 4.0.2 on Mac. Now you can have security of SSH and 2-Factor Authentication, and keep using your favorite Git GUI yay!!.

Steps:

1. Open the app called "Keychain Access" on Mac.

2. Search for "git" and delete all the keys you find (assuming you aren't using those keys for any other things)

3. Go to your home folder

cd ~

4. Delete your .ssh folder (ASSUMING YOU AREN'T USING ANY KEYS IN THERE!!)

rm -rf .ssh

5. Create a new SSH Key

ssh-keygen -t ed25519 -C "your_email@example.com"

6. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

7. At the prompt, type a secure passphrase.

> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

8. Start the ssh-agent in the background.

$ eval "$(ssh-agent -s)"
> Agent pid 59566

9. Check to see if your ~/.ssh/config file exists in the default location.

$ open ~/.ssh/config
> The file /Users/you/.ssh/config does not exist.

10. If the file doesn't exist, create the file.

$ touch ~/.ssh/config

11. Open your ~/.ssh/config file, then modify the file, replacing ~/.ssh/id_ed25519 if you are not using the default location and name for your id_ed25519 key.

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

Note: If you chose not to add a passphrase to your key, you should omit the UseKeychain line.

12. Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.

$ ssh-add -K ~/.ssh/id_ed25519

13. Add the SSH key to your GitHub account.

14. Go to an empty folder and clone your GitHub repo

git clone git@github.com:your_email@example.com:your_username/ProjectName.git

15.

Cloning into 'YourProject'...

The authenticity of host 'github.com (192.30.255.112)' can't be established.

RSA key fingerprint is SHA256:aaaaabbbbbcccccddddeeee.

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.

 16. Open SourceTree and add your account with Auth Type: OAuth, Protocol SSH, then click on "Connect Account". DON'T click on Generate Key, leave that blank.

17. Once you successfully connect, you will see an orange warning icon next to the SSH text. Ignore that, it means nothing.

18. SourceTree will work now with your remotes!!!

Thanks! This fixed the issue for me. Step 14 & 15 was really key to make this work for me. I initially tried cloning the repo through SourceTree but that didn't work. I guess it really needed the known hosts-file that would only get created by cloning via command line.

I'm stuck on this issue also, but the steps above don't work for me. No matter what I do I get the "must add SSH key manually" error when adding a user account, even after I just added the SSH key I'm using to GitHub. :( been stuck on this for week+ now...

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

2,361 views 4 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you