SourceTree on macOS keeps asking for SSH key password, or hangs if password is stored in keychain

Viewed 6626

I've been happily using SourceTree on my Mac for years and rarely had problems. A couple of weeks ago after updating macOS it suddenly stopped working altogether. Whenever I try to clone/fetch/push/pull/whatever to any of my Git repositories, SourceTree either

  1. keeps asking for my SSH key password over and over again immediately after I enter it (if I don't save it in the keychain), or
  2. just hangs forever in the progress window if the password is stored in the keychain.

It's not an issue with the repositories. It's happening for Github too, with the exact same repos and settings that worked before. The key has chmod 400, same as before, and it's the default key ~/.ssh/id_rsa. Tried using the embedded Git in SourceTree and System Git, to no avail. Another app that I switched to in the meantime works normally.

I can't remember exactly which macOS update caused the issues, but I'm now using the latest macOS Catalina 10.15.4 and SourceTree 4.0.1. I wiped the disk completely clean and re-installed everything from scratch due to another problem, but it still doesn't work. I couldn't find anything about new access restrictions that prevent SourceTree from accessing the key itself, or how I could allow access if that's the case. This is driving me nuts, I've switched to another app in the meantime, but I'd really like to continue using SourceTree if it lets me.

EDIT: All my repos are affected by this problem when I'm using SourceTree on macOS. All repos are used by other people as well, it also works for me on my Mac when I use another app. Even SourceTree for Windows on my other laptop, all of those work with the same key.

4 Answers

Thanks for the helpful reply and comments. Turns out SourceTree doesn't add the servers' fingerprints to the ~/.ssh/known_hosts file, and fails silently.

Easy fix - navigate to your repo folder on the command line and run a simple git command, for example:

git fetch origin --dry-run

Nothing will happen since it's a dry run, but the git executable will ask if connecting to the server is ok, and add it to the known_hosts file.

Nothing worked for me until I added this to my .ssh/config:

UseKeychain yes

I faced a similar issue couple of months ago and this is what worked for me. * Open Keychain Access * Under Login/Passwords section look for SourceTree application password * Select the password, right click and delete the password

This time when I entered the password for SourceTree, the app accepted the password without any issues and was saved to the keychain.

There were a couple of things I did that might have contributed to this issue in the first place. I updated my macOS. Around the same time I also enabled two factor authentication in Github. Maybe a conflict between the saved password in the keychain vs the password I was supplying after the update caused the issue. Hope this helps.

According to this post, use these commands in your repo folder, works for me well.

git config credential.helper store
git pull

Related