benpye / wsl-ssh-pageant

A Pageant -> TCP bridge for use with WSL, allowing for Pageant to be used as an ssh-ageant within the WSL environment.
BSD 2-Clause "Simplified" License
619 stars 40 forks source link

Feature request: --setx parameter #24

Open lars18th opened 5 years ago

lars18th commented 5 years ago

Hi,

I'm sure that most of you are using Copy&Paste when running this nice tool. However, a simple workaround exists: The command SETX.

In windows you can use SETX SSH_AUTH_SOCK "\\.\pipe\ssh-pageant" (warning, without the equal sign) and then you have the var in your HKEY_CURRENT_USER user environment. So any program that you run/open after it will receive the var. Tip: You can unset/delete with SETX SSH_AUTH_SOCK ""

So my request is to add the parameter --setx to automatically use SETX to "share" the environment variable at starting AND unset it when finalizing.

I hope you agree! 😉

benpye commented 5 years ago

This is an interesting problem 🙂

My concern with globally setting SSH_AUTH_SOCK on starting and then clearing it on exiting is that if someone happened to modify it after starting, but before closing wsl-ssh-pageant they would surprisingly have the variable cleared. I suppose before clearing we could check that it contains what we expect and deal with it as such.

That said I would be open to having the option to just update the var upon starting, though perhaps shelling out to setx isn't the most elegant method - that said the alternative of modifying the registry is hardly appealing either.

Another option, that could be cool, would be to expose the current pipe through some IPC - this would allow you to put something like $env:SSH_AUTH_SOCK=& wsl-ssh-pageant.exe --query - this is sort of how you can get the current gpg-agent socket.

lars18th commented 5 years ago

Hi @benpye ,

Thank you for your response.

Regarding your comments...

In any case, thank you for discussing about this topic. Regards.