Prerequisites
- OpenSSH in Windows 10
- WSL2
- Golang
Solution
- Run WSL2 container (e. g. Ubuntu):
1ubuntu.exe
- Make a symlink in WSL user home directory to
.ssh
directory from Windows: - Fetch, build and install npiperelay:
- Install
socat
:1sudo apt install socat
- Create state directory for SSH:
1mkdir -p "$XDG_STATE_HOME/ssh" && chmod -R go= "$XDG_STATE_HOME/ssh"
- Add the following to
$HOME/.bashrc
:1export SSH_AUTH_SOCK="$XDG_STATE_HOME/ssh/agent.socket" 2ss -a | grep -q "$SSH_AUTH_SOCK" 3if (( $? != 0 )); then 4 rm -f "$SSH_AUTH_SOCK" 5 ( setsid socat UNIX-LISTEN:"$SSH_AUTH_SOCK",fork,user=$USER,umask=077 \ 6 EXEC:"$HOME/.ssh/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork & ) >/dev/null 2>&1 7fi
- Restart WSL2 container (PowerShell or CMD):
1wsl.exe -t Ubuntu