-
Notifications
You must be signed in to change notification settings - Fork 35
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
Integration with bash on Windows 10 Preview #159
Comments
Nifty. I'll try this out when I get a chance. |
Thanks @katekarnage, never heard of I added this to my
On connecting via SSH I do see this error though, is it something we can safely ignore?
|
It looks like unix sockets are at least partially implemented. microsoft/WSL#134 This is really what should be used here instead of socat. |
Not extremely easy to implement the Unix sockets outside a WSL instance, as far as I can tell. Meanwhile I wrote this: https://gist.github.com/FlorinAsavoaie/8c2b6cb00f786c2caab65b1a51f4e847. |
A major upgrade for Linux subsystem was released |
Still not working for me, even with the new Creators update. I tried to declare the socket in KeeAgent options (both types, msysGit and Cygwin) and then export "SSH_AUTH_SOCK" in bash, but maybe I'm doing it wrong ? |
MSYS/Cygwin use TCP sockets, not Unix sockets, so they will not work with native Linux ssh programs. We need to figure out how to create a Unix socket from a Windows program (if that is even possible) or perhaps automate the |
https://github.com/ionescu007/lxss might help answer this question. I've spent less than 5 minutes looking at this, but it suggests that there is an 'ADSS bus' which is the bridge between the Win32 and WSL environments. It might not really be possible (yet) to just create a socket file from a Win32 program and have it be recognized as such by a WSL process; there would maybe need to be something like the lxext/lxexec method described in the readme for this repo. |
Also fwiw I have been using a modified version of @FlorinAsavoaie's python thing for several months. It works as well or better than the socat method, with the one downside being if I try to close my WSL window(s) while keepass is locked, I get into a db unlock loop that is really hard to get out of. |
WSL from Creators update allows to run arbitrary Linux command from the Windows executable. There's no need to use unofficial tools. |
Does this new capability extend to reading and writing from an Linux socket file? |
Haven't heard about such possibilities. I've posted a link above, maybe it will help. |
I use this now in .bashrc:
It uses the msysgit2unix-socket python script, a recent fork you can find here: |
https://blogs.msdn.microsoft.com/commandline/2017/12/19/af_unix-comes-to-windows/ !! Doesn't interop with WSL yet, apparently, but the blog makes it sound like it will soon-ish, and it's listed in the WSL release notes for 17063... |
Currently working howto: https://gist.github.com/strarsis/e533f4bca5ae158481bbe53185848d49 |
What is cool is that it also works with FileZilla Normal login and some other SSH clients on Windows. |
if [ ! -f /tmp/ssh-agent-pipe ]; then and enable the experimental open ssh support after reading this thread i should've known, that there is already a tcp socket available to bind with socat, but leaving this here for someone who's interested .. |
@pscheit: Where do I have to enable the experimental open ssh support? |
@pscheit: How can I avoid sudo prompt at the beginning of each shell session? |
Hello! I am not a KeeAgent user, but I got a tip that folks here might be interested in wsl-agent-bridge. In short, it allows WSL to transparently use the Windows port of ssh-agent via an AF_UNIX socket. |
This works fine for me.
I had to make some some minor modifications to the script loading #!/usr/bin/env bash
# using pagent / Keepass for Authentication
# see: https://solariz.de/de/ubuntu-subsystem-windows-keepass-keeagent-pageant-linux-ssh.htm
# config
WEASELPAGENTVERSION=1.2
WEASELPAGENTDIR=/path/to/weasel-pageant-$WEASELPAGENTVERSION
# killing old running socket
echo -n "pageant:"
$WEASELPAGENTDIR/weasel-pageant -k >/dev/null 2>/dev/null
eval $($WEASELPAGENTDIR/weasel-pageant -r -a "/tmp/.weasel-pageant-$USER") >/dev/null 2>/dev/null
sleep .5
sshkeysloaded=$(ssh-add -l|grep -c RSA)
if [[ $sshkeysloaded -gt 0 ]] ; then
echo -e "\e[92m OK, ready for Agent forward, loaded $sshkeysloaded keys."
else
echo -e "\e[91m Fail, no keys found or pageant connection failed. "
fi
echo
|
@BWibo, I found the link you provided to be stale, I think the updated links are de Regardless, though, it appears that It's been a year since you provided that script. Are you still using these methods? Have you shifted to something else? I've just updated to wsl2, and I'm trying to determine my options for having a unified windows/GfW/wsl2 ssh experience. Thanks! |
Hey there, I can confirm this working with Ubuntu 20 on WSL 1. However, I have had some issues every now and then, but it works in general. This link works and contains some updates as well: This is what I currently use: #!/usr/bin/env zsh
# see: https://tcpip.wtf/en/linux-ubuntu-subsystem-windows-keepass-keeagent-pageant.htm
# config
WEASELPAGEANTVERSION=1.4
WEASELPAGEANTDIR="$HOME/.weasel-pageant/weasel-pageant-$WEASELPAGEANTVERSION"
echo "WeaselPAgeant v$WEASELPAGEANTVERSION"
# run weasel-pagent
echo -n "pageant:"
eval $("$WEASELPAGEANTDIR/weasel-pageant" -r -b -a "$HOME/.wslsock")
sleep .1
sshkeysloaded=$(ssh-add -l | egrep -c "RSA|ED|SHA" )
if [[ $sshkeysloaded -gt 0 ]] ; then
echo -e "\e[92m OK, ready for Agent forward, loaded $sshkeysloaded keys."
else
echo -e "\e[91m Fail, no keys found or pageant connection failed. "
fi
echo
|
Thanks @BWibo! (I had hoped you were on wsl2 and had found a worthy successor to weasel-pageant.) |
So how can I use KeeAgent within WSL2 ? There's a lot of conflicting results/methods. Thanks |
I haven't found a working solution yet. I suspect I'm mis-using |
One of the reasons I haven't switched to WSL2 is that there is no working KeeAgent integration jet... |
Thanks for the information! I use KeePass + KeeAgent intensively and having issues on WSL 2 would be a blocker, hence I will wait with migration to WSL 2. |
Thanks to the instructions for WSL 2 of the |
Wow awesome ! Tested and totally works. Just at tip for others trying to make it work on WSL 2 using this guide. Extract npiperelay from
In the original guide it says to extract |
@BWibo just for completeness sake, weasel-pagent works just fine with WSL 2. It is still deprecated, but so far it is IMHO the easiest solution until keeagent somehow gets direct WSL(2) support. |
@leonard84: Not trying to be bragging here, but you should check out this HOWTO: Howto: https://gist.github.com/strarsis/e533f4bca5ae158481bbe53185848d49 |
I've just merged a change to allow KeeAgent to work directly with WSL1 and opened a new issue to document the WSL2 workaround (#339). |
The good news is, this already works and should just need some documentation adding to tips and tricks.
Using the MSYSGIT socket functionality already provided, the bash/linux subsystem on windows 10 Preview can be made to use KeeAgent as it's ssh agent.
I managed to do it using socat (apt-get install socat within bash on windows) a script like the one below (pretty crude, ignores some things like proper host/network translation on the port number, because, well... the target architecture is known! and some cleanup could be added to .bash_logout etc)
The text was updated successfully, but these errors were encountered: