Allows you to use ssh keys through ssh-agent on Windows in WSL2 machine. Works with Keepass KeeAgent plugin or open-ssh-agent. This approach uses npiperelay.exe to forward Windows named pipe into WSL2.
- WSL2. You can check version with
wsl --list --verbose
socat
installed in your WSL.
sudo apt install socat
- Dowload repository as zip
- Extract files
- Run install.sh in WSL2
sudo install.sh
- download npiperelay and extract
npiperelay.exe
to/usr/local/bin/npiperelay.exe
- copy
wsl-ssh-agent-forwarder
to/usr/local/bin/wsl-ssh-agent-forwarder
- set execution permissions to
wsl-ssh-agent-forwarder
andnpiperelay.exe
- add line
. /usr/local/bin/wsl-ssh-agent-forwarder
to~/.bashrc
Based on strarsis Gist
It is possible to use systemd service on WSL2 0.67+ instead.
Update your wsl by command wsl --update --web-download
Check what systemd enabled in /etc/wsl.conf
[boot]
systemd=true
Copy wsl-ssh-agent-relay.
service to /etc/systemd/system
folder.
systemctl daemon-reload
systemctl start wsl-ssh-agent-relay.service
systemctl enable wsl-ssh-agent-relay.service
Add export SSH_AUTH_SOCK=/var/run/wsl-ssh-agent.sock
into ~/.bashrc
Wrapper allows using docker command directly from windows converting Windows paths to paths inside WSL.
Uninstall docker-cli if it's installed.
Copy docker.bat
into any location added to PATH. C:\bin
for example
Copy wsl-docker-wrapper
into /usr/local/bin
inside WSL
Set execute permission chmod +x /usr/local/bin/wsl-docker-wrapper
Now you will be able to use docker commands from Windows and don't care about paths while mounting volumes.