3

My ssh keys are stored in KeepassXC (version 2.7.1). I've enabled the SSH Agent integration in KeepassXC and have it use OpenSSH. I tried using Pageant and with "Use both agents" but it doesn't work as it fails to connect to the ssh agent. The KeepassXC is installed on my Windows 10.

I have OpenSSH Authentication Agent running, started and on automatic. With all of this setup, I can see that the keys are loaded by doing ssh-add -l in my powershell.

Following the README guide from this repo https://github.com/rupor-github/wsl-ssh-agent, I have:

  • Installed socat in WSL2
  • Installed wsl-ssh-agent.exe and running in Windows 10.
  • Stored npiperelay.exe in Windows 10 partition (currently in Documents folder).
  • And added to the bottom of my .zshrc file:
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:"/mnt/c/Users/myusername/Documents/wsl-ssh-agent/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork &) >/dev/null 2>&1
fi
  • Ran and restarted my shell with exec zsh or closed and reopened my terminal and tested with ssh-add -l but I get this error message:

error fetching identities: communication with agent failed

I have also tried restarting my KeepassXC and OpenSSH agent service, same error. But I can confirm that the keys are still loaded via my powershell with ssh-add -l.

What am I doing wrong?

Update: My WSL2 is a Debian.

> cat /etc/debian_version
11.3
> ssh -V
OpenSSH_8.4p1 Debian-5, OpenSSL 1.1.1n  15 Mar 2022

My Windows 10

PS C:\WINDOWS\system32> ssh -V
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

Could it be because of the OpenSSH version difference causing the problem?

Update2:

I was able to update my OpenSSH in Windows 10 to the latest version thanks to an answer at a separate question here: https://superuser.com/a/1609071/830668

PS C:\WINDOWS\system32> ssh -V
OpenSSH_for_Windows_8.9p1, LibreSSL 3.0.2

Restarted and tested, the error persists.

2
  • I ran into this exact issue just now and found that a hard restart fixed it. By that I mean shift-clicking Reboot in the Start menu and then selecting Shut down PC in the menu that shows after Windows initially says it's restarting your PC. Then wait for a bit and boot up again. Does that help you? Commented Aug 12, 2022 at 8:56
  • @Justastudent I run this on my laptop. So I always do a full shutdown anyways. Sorry for the late reply. Commented Aug 25, 2022 at 8:01

1 Answer 1

2

This may be an issue with WSL2 interoperability if you have enabled systemd support in WSL.

Check whether /etc/wsl.conf specifies systemd=true in the [boot] section.

If systemd is enabled, you can refer to Microsoft/WSL - Issue 8843 which suggests a mitigation to restore interoperability:

sudo sh -c 'echo :WSLInterop:M::MZ::/init:PF > /usr/lib/binfmt.d/WSLInterop.conf'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .