wsl2-ssh-pageant
wsl2-ssh-pageant copied to clipboard
new wsl2-ssh-pageant.exe instance is create for every gpg communication
Describe the bug This is how I start the process in WSL 2:
setsid socat UNIX-LISTEN:$GPG_AGENT_SOCK,fork EXEC:"$HOME/.ssh/wsl2-ssh-pageant.exe --verbose --gpgConfigBasepath 'C:/Users/user-name/AppData/Local/gnupg' --gpg S.gpg-agent" >/dev/null 2>&1 &
To Reproduce Steps to reproduce the behavior:
- Start a WSL 2 terminal
- Start the
socat
process like above - Repeat
gpg --card-status
3 times - Check the
wsl2-ssh-pageant.exe
process in Windows Task Manager
Expected behavior
No wsl2-ssh-pageant.exe
process should be found in the Task Manager
Screenshots
Desktop (please complete the following information):
- OS: Windows 11
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Additional context
- Gpg4win v4.0.0
- wsl2-ssh-pageant v1.4.0
That is actually intended, each connection attempt opens a new binary. The agent itself is not long lived. The question in this case is: why is the connection held open. The part about gpg is that it's not the main purpose of wsl2-ssh-pageant and was more or less hacked into it. As I'm not using it as my daily driver there needs to be someone who is willing to investigate that issue. Maybe I will find some time to have a look into it myself.
Even if I kill the socat
process in WSL, the wsl2-ssh-pageant
process on the Windows side is still alive. But if I kill the gpg-agent
process on the Windows side, the wsl2-ssh-pageant
processes are gone.
Even if I kill the
socat
process in WSL, thewsl2-ssh-pageant
process on the Windows side is still alive. But if I kill thegpg-agent
process on the Windows side, thewsl2-ssh-pageant
processes are gone.
I must admit that I never noticed that the wsl2-ssh-pageant proccesses are lacked behind. But I can indeed confirm it's happening for me too. I would assume there ist something in the teardown process which results in this behavior. I've tried to look into it but did not find any obvious reasons. I totally understand that this is not the expected behavior but on the other hand on most modern computers this shouldn't make a huge difference. If the computer is rebooted frequently. Nevertheless I will mark this as an issue which needs to be addressed, but I have no concrete timeframe.
Well, in my case, my desktop is usually on throughout the day and went to hibernation during the night. I rarely restart or shut down my computer unless I have to.
While reading the code, I noticed you opened a connection here. But I wonder if you need to manually close it. I don't have much knowledge of go.
I tried in ssh mode. I observed that the wsl2-ssh-pageant
process appeared on Windows for a short time, then exited.
@davidshen84 I download wsl2-ssh-pageant
file from your repository and run 3 times gpg --card-status
. wsl2-ssh-pageant.ext
processes not closes
@FFxSquall
Thanks, I just tested the one from the github artifactory and I can reproduce the issue. However, the one compiled on my local does not have this issue.
I think the real problem the the -H=windowsgui
option which, according to this, creates a GUI binary. I don't think we need a GUI binary for this tool. I will update my PR to build a console binary.
Thanks
@FFxSquall
Please give it another try. https://github.com/davidshen84/wsl2-ssh-pageant/actions/runs/2063498454
@davidshen84 It's works. Thanks
@davidshen84 I've tried this on my system as well, and it appears to resolve the issue. The added Close handler doesn't seem to be called with our without the windows gui option. One note, might want to also remove the compile option from the Makefile. Much appreciated!