11

I'm trying to connect to GitHub through SourceTree on OS X using SSH. Even though I can connect fine command line, I can't seem to work with any repo through SSH in SourceTree with the error:

Permission denied (publickey).

All the help topics I have found online suggest configuring the SSH client in SourceTree. However, all of that documentation is for the Windows version. How can I access the SSH Preferences on the OS X version of SourceTree?

19

It was hard to find this answer, but it looks like the way to do this is to just add the ssh key to your keychain in Mac OS. I found an answer here: https://wiki.hpcc.msu.edu/display/hpccdocs/Adding+a+Private+Key+to+Your+Mac+OSX+Keychain

From the link:

On Mac OSX, the native SSH client can use the built-in keychain directly. To add your private key to the keychain simply use the command:

ssh-add -K /path/of/private/key

As an example if your private key is stored at ~/.ssh and is named id_rsa, you would use the command:

ssh-add -K ~/.ssh/id_rsa

You will then be prompted for your passcode, which will be stored in your keychain. After this you should be ready for a password-less login.

After I added my SSH key, SourceTree started authenticating correctly.

1/18/2017 EDIT: Apparently OSX Sierra made it so you don't get your keys back when you login, so you'll have to do this every time you start your computer. BUT, there's a nice way to fix this from the Apple stack exchange: https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically

Just follow the steps in the answer with "Update Jan 2017"

0

I tried to google this as well, since adding custom SSH Keys with OpenSSH is available in the Tools section in SourceTree(ST) for Windows.

Although I was able to ssh -T successfully from terminal, ST for Mac was denying access.

Finally, I thought of adding the keys to my agent again. Now, when I checked the list of identities added - there were none (ssh-add -l). Just add your ssh key to the agent and ST will automatically pick your key and grant access.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.