Skip to content

Instantly share code, notes, and snippets.

@thfrei
Created June 9, 2026 11:58
Show Gist options
  • Select an option

  • Save thfrei/19a8f4673dd44bcf2c1f8ea0437875ff to your computer and use it in GitHub Desktop.

Select an option

Save thfrei/19a8f4673dd44bcf2c1f8ea0437875ff to your computer and use it in GitHub Desktop.
WSL openssh access windows npiperelay
# WSL openssh cannot access the ssh keys stored in the windows openssh server.
# with npiperelay it can, redirecting the socket
# checkout: https://github.com/jstarks/npiperelay
#!/bin/bash
cd ~;
echo "Install socat and unzip"
sudo apt -y install socat unzip
echo "Get npiperelay";
wget https://github.com/jstarks/npiperelay/releases/latest/download/npiperelay_windows_amd64.zip
unzip -o npiperelay_windows_amd64.zip -d npiperelay
rm npiperelay_windows_amd64.zip
echo "update env vars for ssh socket, add to .bashrc"
cat << 'EOF' >> ~/.bashrc
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
ss -a | grep -q $SSH_AUTH_SOCK
if [ $? -ne 0 ]; then
rm -f $SSH_AUTH_SOCK
(setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$HOME/npiperelay/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork &) >/dev/null 2>&1
fi
EOF
echo "Reload ~/.bashrc"
exec bash
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment