Since people still seem to be having problems with this, I thought I would post my solution for getting a pretty reliable agent into WSL2.
I have found the npipe+socat options pretty unstable, and frustrating.
My solution for getting an agent into WSL uses a combination of WSL2 systemd support, OpenSSH server installed in WSL2, and using OpenSSH client in Windows.
Prepare the environment
- Install the openssh client on windows, run some kind of agent on Windows and add your keys. Make sure you can see your keys on the Windows side by running
ssh-add.exe -L
- Setup your favorite WSL distro configure for WSL2.