kikikey
kikikey

Reputation: 105

Git credential helper doesn't work on windows subsystem for linux

I am using Ubuntu in WSL on Windows 10 and I have git installed in WSL and use it regularly. I have a very annoying problem where I try to cache my github credentials so I don't have to constantly enter my username/password when commiting but it doesn't work. I follow the exact instructions provided by github verbaitim. First I enter:

git config --global credential.helper cache

then I enter:

git config --global credential.helper 'cache --timeout=2629800'

but nothing happens, I still have to constantly enter my github username and password

EDIT:

To clarify I'm doing all this through the bash terminal on ubuntu wsl and I am not using the windows version of git. I am using the version of git that was included in ubuntu. All these commands I entered are linux commands.

Upvotes: 4

Views: 4500

Answers (2)

Nolan Strait
Nolan Strait

Reputation: 455

You could use SSH instead of HTTP. Once set up, you only have to input your SSH password upon booting WSL.

After trying several methods on WSL 2, this is what worked for me. I chose to host my SSH keys within WSL instead of Windows.

Follow GitHub's guide for adding a new SSH key to your GitHub account if you haven't done so already. Be sure to select "Linux" (for WSL) near the top of this page.

Install keychain:

sudo apt install keychain

Then add the following line to your shell's configuration file (likely ~/.bashrc or ~/.zshrc):

eval `keychain --quiet --eval --agents ssh id_rsa`

Now you will only have to enter your password when booting WSL!

Thank you Birk Holland for this article on sharing SSH keys between Windows and WSL 2.

Upvotes: 1

max630
max630

Reputation: 9238

Probably the reason is incomplete support for Unix domain sockets in WSL

You can use instead the windows credential manager: https://www.edwardthomson.com/blog/git_credential_manager_with_windows_subsystem_for_linux.html

From the link, here is how to enable it:

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"

Upvotes: 9

Related Questions