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
612 stars 40 forks source link

Strange errors with Gpg4Win #40

Closed NewRedsquare closed 3 years ago

NewRedsquare commented 4 years ago

Hello,

I'm the owner of a Gnuk Token (still a smartcard 💯 ), and i followed all the steps to have ssh-based key working. The problem is, i've got strange errors from the wsl-ssh-pageant.exe CMD with Admin rights :

C:\Users\Romain>C:\wsl\wsl-ssh-pageant.exe --wsl c:\wsl\ssh-agent.sock --verbose
2020/05/16 20:22:37 Listening on Unix socket: c:\wsl\ssh-agent.sock
2020/05/16 20:22:40 New connection: &{{0xc000182000}}
2020/05/16 20:22:40 Pageant query error 'WM_COPYDATA failed'
2020/05/16 20:22:40 io.ReadFull error 'EOF'
2020/05/16 20:22:44 New connection: &{{0xc0000d0000}}
2020/05/16 20:22:44 Pageant query error 'Could not find Pageant window'
2020/05/16 20:22:44 io.ReadFull error 'EOF'
2020/05/16 20:22:46 New connection: &{{0xc00007f900}}
2020/05/16 20:22:46 Pageant query error 'Could not find Pageant window'
2020/05/16 20:22:46 io.ReadFull error 'EOF'
2020/05/16 20:22:47 New connection: &{{0xc00007fb80}}
2020/05/16 20:22:47 Pageant query error 'Could not find Pageant window'
2020/05/16 20:22:47 io.ReadFull error 'EOF'
2020/05/16 20:23:08 New connection: &{{0xc0000d0280}}
2020/05/16 20:23:08 Pageant query error 'WM_COPYDATA failed'

( C:\wsl is not the path of WSL, if it matters ) i run Debian's WSL.

In WSL, here is the content added to my .bashrc :

gpg-connect-agent.exe /bye
gpg-connect-agent.exe "scd serialno" "learn --force" /bye
SSH_AUTH_SOCK=/mnt/c/wsl/ssh-agent.sock

I'm running the last version of Gpg4win. I hope there is a solution or someone will find out that i made stupid errors 🥇 .

Romain.

benpye commented 4 years ago

If I were to guess it could be because you're running from an admin command prompt - what happens if you run from a non elevated cmd?

NewRedsquare commented 4 years ago

Same issue with non-admin cmd :/ It seems like the error kills gpg-connect-agent which throws the error Could not find Pageant window

2020/05/20 11:37:56 New connection: &{{0xc000086000}}
2020/05/20 11:37:56 Pageant query error 'Could not find Pageant window'
2020/05/20 11:37:56 io.ReadFull error 'EOF'
2020/05/20 11:37:59 New connection: &{{0xc00007f900}}
2020/05/20 11:37:59 Pageant query error 'Could not find Pageant window'
2020/05/20 11:37:59 io.ReadFull error 'EOF'
2020/05/20 11:38:54 New connection: &{{0xc00007fb80}}
2020/05/20 11:38:54 Pageant query error 'WM_COPYDATA failed'
2020/05/20 11:38:54 io.ReadFull error 'EOF'
2020/05/20 11:38:55 New connection: &{{0xc000164000}}
2020/05/20 11:38:55 Pageant query error 'Could not find Pageant window'
2020/05/20 11:38:55 io.ReadFull error 'EOF'
benpye commented 4 years ago

Just as a sanity check does this work with Putty's Pageant? I'll see if I see any issues with a more recently Gpg4Win, mine is probably out of date.

NewRedsquare commented 4 years ago

You mean running pageant then using ssh login with Putty ? ( i'm not familiar with )

rouben commented 3 years ago

I can confirm the same issue which was resolved by launching gpg-agent. Apparently changing gpg-agent configuration with gpgconfig caused the process to be killed.

benpye commented 3 years ago

@rouben Thanks for the update. I've not seen this issue in my config.

prognaest commented 1 year ago

I have run into this same issue on a new device. The configuration works with older versions on other devices.

gpg-version: 2.3.8 Gpg4win: 4.0.4 WinSSH-Pageant: 2.2.0

PS C:\Users\username> .\wsl-ssh-pageant-amd64.exe --winssh ssh-pageant --verbose
2022/12/12 10:12:50 Listening on named pipe: \\.\pipe\ssh-pageant
2022/12/12 10:13:03 New connection: &{0xc00005abe0 \\.\pipe\ssh-pageant}
2022/12/12 10:13:03 Pageant query error 'WM_COPYDATA failed'
2022/12/12 10:13:03 io.ReadFull error 'EOF'
PS C:\Users\username> gpg-agent.exe --daemon --verbose
gpg-agent[10600]: Es wird auf Socket `C:\\Users\\username\\AppData\\Local\\gnupg\\S.gpg-agent' gehört
gpg-agent[10600]: Es wird auf Socket `C:\\Users\\username\\AppData\\Local\\gnupg\\S.gpg-agent.extra' gehört
gpg-agent[10600]: Es wird auf Socket `C:\\Users\\username\\AppData\\Local\\gnupg\\S.gpg-agent.browser' gehört
gpg-agent[10600]: Es wird auf Socket `C:\\Users\\username\\AppData\\Local\\gnupg\\S.gpg-agent.ssh' gehört
gpg-agent[10600]: gpg-agent (GnuPG) 2.3.8 started
gpg-agent[10600]: putty message loop thread started

It looks like winssh-pageant isn't able to communicate with gpg-agent. My smartcard is readable by gpg --card-status. My gpg-agent.conf looks like this:

###+++--- GPGConf ---+++###
enable-ssh-support
enable-putty-support
###+++--- GPGConf ---+++### 12.12.2022 10:12:23 Mitteleuropäische Zeit
# GPGConf edited this configuration file.
# It will disable options before this marked block, but it will
# never change anything below these lines.

You asked in a past comment:

Just as a sanity check does this work with Putty's Pageant? I'll see if I see any issues with a more recently Gpg4Win, mine is probably out of date.

I would love to test that, but I don't really know what you mean by that.