Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: osxkeychain credential helper silently fails to remember username/password

This page and many like it gives instructions for setting up the osxkeychain credential helper with git. I've followed these instructions; everything seemed to work fine. I can see that my username and password in the Keychain Access application are correct and that git-credential-osxkeychain has access to the github.com record. When I type git config -l I can see the entry credential.helper=osxkeychain as well as correct user.name and user.email entries. When I run git credential-osxkeychain I see the usage message I'm apparently supposed to. At no point do I receive an error message. Everything seems to be setup correctly.

However, no matter how many times I git push a particular repository, it always asks for my username and password. Entering the username and password found in my Keychain Access entry works; so it does not appear to be a login issue. Additionally, when I type git credential-osxkeychain erase (or git-credential-osxkeychain erase), the command hangs silently and, as far as I can tell, indefinitely.

I have, as of yet, been unable to find anything documenting this issue. This question raises a similar issue, but my git version is 2.6.4, so the solution is not helpful. Why is it doing this and how do I get git to remember my username and password with the osxkeychain credential helper?

I'm using Mac OS X 10.11.4 and git version 2.6.4.

like image 536
nben Avatar asked Aug 16 '16 16:08

nben


People also ask

How do I get Git to remember my username and password?

If you're cloning GitHub repositories using HTTPS, you can use a credential helper to tell Git to remember your GitHub username and password every time it talks to GitHub. Turn on the credential helper so that Git will save your password in memory for some time. By default, Git will cache your password for 15 minutes.

How do I turn off credential helper in Git?

Since the credential. helper key is a multi-valued config list, there's no way to "unset" a helper once it's been set. So if your system /etc/gitconfig sets one, you can never avoid running it, but only add your own helpers on top. Since an empty value for credential.

How do I add Git credentials to keychain on Mac?

Updating your credentials via Keychain AccessType Keychain access then press the Enter key to launch the app. In Keychain Access, search for github.com. Find the "internet password" entry for github.com . Edit or delete the entry accordingly.

How do I update my Git credential helper?

To update your credentials, go to Control Panel → Credential Manager → Generic Credentials. Find the credentials related to your Git account and edit them to use the updated password. This should be the accepted answer if git config --list contains credential. helper=wincred .


1 Answers

Edit ~/.ssh/config and add UseKeychain yes to every host you want the Keychain to remember the password for.

For example, if you are trying to do this for GitHub:

Host github.com
    IdentityFile ~/.ssh/your_github_cert_rsa
    UseKeychain yes

If you want to enable it for every host, just add:

Host *
    UseKeychain yes

This is a new requirement, added by Apple on macOS Sierra 10.12.2, you can learn more about it running man ssh_config in 10.12.2:

UseKeychain

             On macOS, specifies whether the system should search for
             passphrases in the user's keychain when attempting to use a par-
             ticular key. When the passphrase is provided by the user, this
             option also specifies whether the passphrase should be stored
             into the keychain once it has been verified to be correct.  The
             argument must be ``yes'' or ``no''.  The default is ``no''.

Under Mac OS 10.11, you can check if the keychain is disabled with the variable

KeychainIntegration
  Specifies whether to enable Keychain support on Mac OS X.  
  If Keychain support is enabled, then passwords for identities can be 
  managed via the Mac OS X Keychain.
  The value for this keyword must be ``yes'' or ``no''.  The default is ``yes''.
AskPassGUI
  Show the system password prompt
like image 132
andresgottlieb Avatar answered Oct 19 '22 06:10

andresgottlieb