How to serve SSH keys to
ssh running in WSL (Ubuntu) from KeeAgent running in Windows 10.
Using KeeAgent with WSL
WSL (Windows Subsystem for Linux) has been gaining popularity in recent years, as it allows running an Ubuntu shell from within Windows. Its architecture involves a degree of separation and so there are additional steps to get ssh in WSL/Ubuntu talking to KeeAgent running in Windows.
Although weasel-pageant is meant to allow usage of Pageant keys from WSL, it works just as well for our use case, since KeeAgent is also compatible with Putty.
Extract the zip in Windows, not in WSL. You can place it anywhere. If you’re keeping with the portable theme, it can be placed in a synched directory near Keepass and your KDBX.
Tell WSL to use it
You will then need to tell WSL to talk to the weasel-pageant. In WSL, add the following lines to
~/.bashrc, remember to modify
weaselpath to match the directory where you extracted weasel-pageant.
weaselpath="/mnt/c/Users/mendhak/Google Drive/Documents/keys/wsl-pageant-helper/" echo -n "pageant loading, wait..." "$weaselpath/weasel-pageant" -k> /dev/null 2> /dev/null eval $("$weaselpath/weasel-pageant" -r -a "/tmp/.weasel-pageant-$USER")> /dev/null 2> /dev/null sleep 1 sshkeysloaded=$(ssh-add -l | grep -c SHA) if [[ $sshkeysloaded -gt 0 ]]; then echo -e "Loaded $sshkeysloaded keys." else echo -e "Failed to load any keys." fi
In WSL, Windows paths are prefixed with
C:, and paths with spaces require double quotes around them.
If you’ve changed your WSL mount point to
/c/, be sure to reflect that in the path above.
Reload a WSL bash session and you should see
pageant loading, wait... at the top. Once your bash prompt appears, test a connection to Github as usual.
ssh -T [email protected]