Using the SSH agent in WSL2
Topics: Secure Shell, Windows Subsystem for Linux
The keychain utility makes using Secure Shell with passphrase authentication much easier. It detects if an SSH agent process is already running; if not, it’ll start one. Via ssh-askpass, it’ll also make sure the agent knows your passphrase.
Setup
Install packages:
apt install keychain ssh-askpass
Add this to your shell startup script(s):
/usr/bin/keychain -q --nogui ~/.ssh/id_rsa
source ~/.keychain/$(hostname)-sh