jstarks / npiperelay

npiperelay allows you to access Windows named pipes from WSL
MIT License
660 stars 71 forks source link

copy from stdin to pipe failed #13

Open bendem opened 4 years ago

bendem commented 4 years ago

Hi all, I'm trying to follow this article to forward msys2's ssh-agent request to the "native" windows openssh agent using this command:

socat UNIX-LISTEN:/tmp/ssh-agent-pipe EXEC:"npiperelay.exe -ep -v -s //./pipe/openssh-ssh-agent"

and I'm getting this error:

2020/06/03 15:36:00 connecting to //./pipe/openssh-ssh-agent
2020/06/03 15:36:00 connected
2020/06/03 15:36:00 copy from stdin to pipe failed: read /dev/stdin: invalid argument.

which I don't quite understant. I've done quite a bit of research, but I'm no go developer nor windows expert and I'm stuck with this error and no idea how to fix it. I found https://github.com/uber-go/zap/issues/328 which says something about the error being ignorable, but commenting the log.Fatalln call after io.Copy doesn't fix the problem.

Let me know how I can help, <3

ttk commented 1 year ago

Although the documented steps for wsl work flawlessly, for msys2 it gave me the same error you reported. I found a solution by simply adding the pipes modifier on the EXEC command. i.e.

socat UNIX-LISTEN:/tmp/ssh-agent.sock,fork EXEC:"npiperelay.exe -ep -s //./pipe/openssh-ssh-agent",pipes

as suggested in this post. socat can be installed in mysys2 via pacman -S socat.

I also confirmed that using putty's plink also works (if you don't want to compile npiperelay):

socat UNIX-LISTEN:/tmp/ssh-agent.sock,umask=066,fork EXEC:"PLINK.EXE -serial //./pipe/openssh-ssh-agent",pipes

where you can download plink.exe from putty's download page and place it in your PATH.

ttk commented 1 year ago

I found that my suggestion above, for msys2, doesn't work when using agent forwarding. Yet it works from WSL. The only difference between the two are the socat binary and the nofork vs pipes modifier. It's so close to working perfectly...