I’ve been developing with Windows WSL2 system several months now, and I only have had couple of issues. One of them is that I’ve been forced to enter passphrase every time when I use SSH or pull from Git for example. So annoying.
I tried all the tutorials that I could find but nothing seems to work. But Ubuntu keychain package worked for me!
First, install keychaing in terminal:
sudo apt install keychain
Second, add these lines in your
/usr/bin/keychain --nogui ~/.ssh/id_rsa source $HOME/.keychain/$HOSTNAME-sh
If the variable
$HOSTNAME doesn’t work get your hostname with command:
$HOSTNAME with your computers hostname:
/usr/bin/keychain --nogui ~/.ssh/id_rsasource $HOME/.keychain/YOUR-HOSTNAME-sh
With this I now only have to enter passphrase only once when I open my laptop or reboot. Much better and I’m totally OK to enter it once a day.
Note that I’m not trying to share SSH key between Windows and WSL2. At the moment I only develop inside WSL2.