Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use wsl2 agent socket #3

Closed
tommy2d opened this issue Nov 8, 2022 · 10 comments · Fixed by #6
Closed

Unable to use wsl2 agent socket #3

tommy2d opened this issue Nov 8, 2022 · 10 comments · Fixed by #6

Comments

@tommy2d
Copy link

tommy2d commented Nov 8, 2022

I previously used the native OpenSSH agent in windows 11 which was forwarded to WSL2, which worked. I'm now trying your solution, and thus I disabled the SSH agent service in windows. Native ssh through powershell is working fine. I can't seem to get WSL2 to work, even though the env vars seem to be alright and the socket is created in /tmp.

ssh-add -L yields the following the error:

error fetching identities: communication with agent failed

How should I debug this?

@unreality
Copy link
Owner

unreality commented Nov 8, 2022

@tommy2d can you check that socat is installed in your WSL2 VM? The script will silently fail if its not installed, so check that first...

If thats installed and the socket is created properly, it could be that the socket id created by nCryptAgent is already in use by something else? Are you running any other tools that have WSL2 communication interop? If you are try quitting them and re-trying.

@farcaller
Copy link

Same issue here and I do have socat installed (and it is in fact running after executing the snippet).

@unreality
Copy link
Owner

unreality commented Nov 9, 2022

I'll see if i can reproduce this with a Win11 VM Ive reproduced it on my Win11 VM so i'll see if i can find out whats going on

I'll put out a new version later today which will output logs into the appdata directory to help debug this...

@tommy2d
Copy link
Author

tommy2d commented Nov 9, 2022

Same here: socat is in fact installed & running and was also used by my previous wsl2 solution. I'll try your updated version later today.

@unreality
Copy link
Owner

unreality commented Nov 9, 2022

Here is the workaround until I add some checks and an installer:

Create ncrypt.reg with the following content:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\GuestCommunicationServices\22223333-facb-11e6-bd58-64006a7986d3]
"ElementName"="nCryptAgent"

and install it by opening the .reg file. Alternatively create the registry entry by hand.

@farcaller
Copy link

Ha, I thought that was it based on the docs. The registry entry does indeed work as expected.

@tommy2d
Copy link
Author

tommy2d commented Nov 9, 2022

I'm afraid it is still not working for me, even after importing the .reg. Is there anything else I can do to help?

@tommy2d
Copy link
Author

tommy2d commented Nov 9, 2022

When I run socat in foreground and I execute ssh-add -L, it complains like this:

socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork VSOCK-CONNECT:2:0x22223333
2022/11/09 23:16:01 socat[229] E unknown device/address "VSOCK-CONNECT"

@tommy2d
Copy link
Author

tommy2d commented Nov 9, 2022

Fixed it: my default wsl2 VM was apparently running an older version of Ubuntu, bundled with an older version of socat:

Working:
bookworm/sid
Version: 1.7.4.1-3ubuntu4

Not working
bullseye/sid
Version: 1.7.3.3-2

We should probably update the shell scripts to verify that socat is compatible.

@unreality
Copy link
Owner

This should be fixed in v0.0.5, but you will need to update your WSL shell script since I changed the socket identifier to avoid conflicts with other software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants