You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Amazing! thank you. I've been fighting this forever. I can't believe that Sourcetree never can get this right
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This worked for me as well. Like Eric, steps 14 and 15 are what did it for me. I tried many other things previously (including every other step in this list), and nothing seemed to do the trick until I did those things. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you may check the permissions on the ~/.ssh/config file, it needs to be 600.
chmod 600 ~/.ssh/config
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you ever find another answer. I also tried the above approach and it did not solve my problem. When I try the following it fails:
ssh-add -l -E SHA256
The agent has no identities.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.