Packages needed in WSL:
- tmux
- socat
Files needed in Windows:
- wsl-ssh-pageant: https://github.com/benpye/wsl-ssh-pageant
- npiperelay: https://github.com/jstarks/npiperelay
Put wsl-ssh-pageant.exe and npiperelay.exe in %UserProfile%\bin
Shortcut: %UserProfile%\bin\wsl-ssh-pageant.exe -systray --winssh ssh-agent
The named pipe can be enabled in KeeAgent settings, which makes wsl-ssh-pageant unnecessary. https://keepass.info/plugins.html#keeagent
if [ ! -S /tmp/wsl-auth-sock ] && [ -z "$TMUX" ] && [ ! $(pgrep socat) ]; then
echo "Starting socat relay to ssh-pageant"
tmux new-session -d -s socat-ssh-agent
tmux send-keys '/usr/bin/socat UNIX-LISTEN:/tmp/wsl-auth-sock,fork EXEC:"/mnt/c/Users/$USER/bin/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork' C-m
fi
check_auth_socket() {
powershell.exe "[System.IO.Directory]::GetFiles(\"\\\\.\\\\pipe\\\\\") | Select-String \"agent\""
}
export SSH_AUTH_SOCK=/tmp/wsl-auth-sock