Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 677
Paco1 Avatar asked May 26 '20 15:05

Paco1


People also ask

How do I update my SourceTree credentials on Mac?

In Mac, it can be changed by clicking on Gear icon > Accounts. Alternatively, you can go to the "Keychain Access" utility on the Mac, search for the remote password and delete the stored key. Then the next time you start SourceTree, it will ask you for your new credentials. Let us know if this worked for you!

How do I link my SSH key to SourceTree?

From Sourcetree, open the PuTTY Key Generator dialog by going to Tools > Create or Import SSH Keys. Click Load, navigate to your SSH folder, and click the private key. Make sure you're looking at All files if you don't see your private key. Enter your passphrase for the SSH key and click OK.

Where does SourceTree store passwords?

1 answer. The credentials are stored in the Windows' Credential Manager, under the Windows Credentials section, stored with a 'git:' prefix.

How do I authenticate in SourceTree?

In the Edit Hosting Account window, select the drop-down for Authentication and select Basic. Ensure your username is correct. Ensure you are using an app password and that it is also correct (ensure there is no copy and paste error when copying the app password over to Sourcetree for Windows).


2 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.

like image 111
Paco1 Avatar answered Sep 26 '22 03:09

Paco1


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

UseKeychain yes
like image 26
spartygw Avatar answered Sep 24 '22 03:09

spartygw