WSL2 & Keychain
2022-12-08 (updated 2025-10-25)Notes | 1 min read
#linux #ssh #wsl
The problem
If you use ssh-agent with an encrypted ssh key it does not persist when you open a new terminal window.
The solution
Use keychain instead.
- Install
sudo apt install keychain - Add to your shells rc file, eg.
.bashrcor.zshrc# Repeat this line for all keys you want to unlock and use this way /usr/bin/keychain -q --nogui $HOME/.ssh/id_rsa source $HOME/.keychain/wsl-sh - Unlock your keys on shell startup and enjoy