I run Windows 10 with WSL. I have the desired behaviour on one computer, but cannot replicate elsewhere. Here's what I'm after:
Things I've tried:
eval $(ssh-agent)
, followed by ssh-add
; it will remember the passphrase, but if I put it in my ~/.bash_profile
then it prompts me for every new console window, and I open a lot - many of which I'm not using git in.git config --global credential.helper
to cache
or store
bash.exe
and wsl.exe
to get git-credentials-manager.exe
to workHere's an example of what I've put in my ~/.gitconfig
:
[credential]
helper = "/mnt/c/Program\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"
I've installed the git credential manager
from here and have also tried the main Git For Windows installation as an alternative.
How can I encourage it to remember my passphrase?
I tried the option to add AddKeysToAgent yes
to ~/.ssh/config
but it doesn't keep it between new tabs on the terminal.
The best solution I found so far is to do the following:
sudo apt install keychain
Find your hostname using the terminal:
hostname
Then add the following to your ~/.bashrc
or ~/.zshrc
file:
/usr/bin/keychain --nogui ~/.ssh/id_rsa
source $HOME/.keychain/YOUR-HOSTNAME-HERE-sh
Now, each time you reboot, you’ll have to enter your passphrase. But you only have to do it one time until you reboot or terminate WSL.
If you want to use the same key you already have on Windows you can follow this post Sharing SSH keys between Windows and WSL 2