** This is a updated Posting from my older German Article **

I don't want to give a rating of the Subsystem for Linux, for some it is very useful others feel maybe not so happy about it, but lets get straight to the point.

The most Pain I had is having my Private Key in the Subsystem and need to reauth everytime by entering the Key. I'm used to using the Keepass integrated (plugin) Agent and thats why my Key have a to long Password to type.

In Ubuntu for Windows the nativ pageant Support from a in windows initialized Pagent is not possible because the System "Lives" within another Layer of the OS.
The Solution is a Agent Helper.
 

Installation

  1. Download the latest ZIP Files of Vuoris pagent Release Seite 
  2. Extract into a Folder which can be accessed from within your WSL Linux
    Therefore I created a extra directory in my Windows User homedir. That Directory I added as a symbolic Link to my WSL, See Screenshot:
    Konsole SSH Linux Subsystem Windows Bash Ubuntu
  3. Edit the .bashrc in your WSL Homedir
  4. Add following Code at the end, please adjust the Agent Path  (/mnt/c/Users/mg/…)

# using pagent / Keepass for Authentication
# see: https://tcpip.wtf/en/linux-ubuntu-subsystem-windows-keepass-keeagent-pageant.htm

# Getting exec location
# I use this script on several Computers, to easy have it copy and paste
# I added those "Path finding"...
# If you know the Path is fixed for you, just set it as WEASEL 
if [ -f "/mnt/c/path-to-pageant/weasel-pageant-1.4/weasel-pageant" ]; then
	WEASEL="/mnt/path-to-pageant0/weasel-pageant-1.4/weasel-pageant"
elif [ -f "/mnt/d/another-path-to-pageant/weasel-pageant-1.4/weasel-pageant" ]; then
	WEASEL="/mnt/d/another-path-to-pageant/weasel-pageant-1.4/weasel-pageant"
elif [ -f "/mnt/e/another-path-to-pageant/weasel-pageant-1.4/weasel-pageant" ]; then
	WEASEL="/mnt/e/another-path-to-pageant/weasel-pageant-1.4/weasel-pageant"
fi

if [ -f "$WEASEL" ]; then
	echo -n "pageant:"
    # killing old running socket
	"$WEASEL" -k >/dev/null 2>/dev/null
    # starting new
	eval $($WEASEL -r -q) >/dev/null 2>/dev/null
	sshkeysloaded=$(ssh-add -l|grep -c SHA)
	if [[ $sshkeysloaded -gt 0 ]] ; then
	    echo -e "\e[92m OK, ready for Agent forward, loaded $sshkeysloaded keys."
	else
	    echo -e "\e91m Fail, no keys found or pageant connection failed. "
	fi
	echo
fi


That's actually all. As soon as you start a new WSL the .bashrc gets loaded and weasel PAGEANT Loads the Keys provided within your Windows Pageant enviroment.


KeeAgent for Keepass

✉ MG// CEST
Follow Icon