carlolars / wsl-gap

wsl-gap is a gpg-agent proxy for closing the gap between WSL and the Windows gpg-agent.
MIT License
8 stars 1 forks source link

gpg: selecting card failed: No such device #1

Open axieum opened 2 years ago

axieum commented 2 years ago

Hi,

Thank you so much for this package, super simple to set up with the provided wsl-gap.ssh bootstrap script! šŸ™Œ

I've got the ssh-add -l working, it successfully lists my authentication key from my YubiKey. However, the gpg --card-status displays -

image

wsl-gap.exe.log

01:59:24 [ INFO] data_dir() -> "C:\\Users\\jonathan\\AppData\\Roaming"
01:59:24 [ INFO] find gpg-agent
01:59:24 [ INFO] start ssh-proxy
01:59:24 [ INFO] request read from stdin, length: 5
01:59:24 [ INFO] request: [0, 0, 0, 1, 11]
01:59:24 [ INFO] agent_query
01:59:24 [ INFO] response received, length: 85
01:59:24 [ INFO] response written
01:59:24 [ INFO] request read from stdin, length: 0
01:59:24 [ INFO] request: []
01:59:24 [ INFO] done

Windows Version Info

PS C:\Users\jonathan> ssh -V
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
PS C:\Users\jonathan> gpg --version
gpg (GnuPG) 2.3.8
libgcrypt 1.10.1
Copyright (C) 2021 g10 Code GmbH
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: C:\Users\jonathan\AppData\Roaming\gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
AEAD: EAX, OCB
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
PS C:\Users\jonathan> gpgconf
gpg:OpenPGP:C%3a\Program Files (x86)\GnuPG\bin\gpg.exe
gpgsm:S/MIME:C%3a\Program Files (x86)\GnuPG\bin\gpgsm.exe
keyboxd:Public Keys:C%3a\Program Files (x86)\GnuPG\bin\keyboxd.exe
gpg-agent:Private Keys:C%3a\Program Files (x86)\GnuPG\bin\gpg-agent.exe
scdaemon:Smartcards:C%3a\Program Files (x86)\GnuPG\bin\scdaemon.exe
dirmngr:Network:C%3a\Program Files (x86)\GnuPG\bin\dirmngr.exe
pinentry:Passphrase Entry:C%3a\Program Files (x86)\GnuPG\..\Gpg4win\bin\pinentry.exe

image

WSL Version Info

[jonathan@Adair ~]$ ssh -V
OpenSSH_9.1p1, OpenSSL 3.0.7 1 Nov 2022
[jonathan@Adair ~]$ gpg --version
gpg (GnuPG) 2.2.40
libgcrypt 1.10.1-unknown
Copyright (C) 2022 g10 Code GmbH
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /home/jonathan/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
[jonathan@Adair ~]$ gpgconf
gpg:OpenPGP:/usr/bin/gpg
gpgsm:S/MIME:/usr/bin/gpgsm
gpg-agent:Private Keys:/usr/bin/gpg-agent
scdaemon:Smartcards:/usr/lib/gnupg/scdaemon
dirmngr:Network:/usr/bin/dirmngr
pinentry:Passphrase Entry:/usr/bin/pinentry
axieum commented 2 years ago

It seems the SSH works in WSL but not on Windows, and the GPG works on Windows but not on WSL šŸ˜•

carlolars commented 2 years ago

Hi @axieum!

I tried the gpg commands in WSL2 and none of them works for me anymore šŸ˜ž I'll see if I can squeeze in some debug-time and try to find the root cause.

axieum commented 2 years ago

I ended up at this comment which uses socat to launch a new jstarks/npiperelay process for a named pipe. I'm not sure if this is of any help to you.

I managed to get ssh-add -l working on the Windows side (on the native Windows OpenSSH client) by following this step of a seemingly abandoned project: benpye/wsl-ssh-pageant#how-to-use-with-windows-10-native-openssh-client. I wonder if we can fit this into this project also, so we can use ssh-add -l on the Windows side. šŸ¤”

lucasfcnunes commented 8 months ago

Hi @axieum!

I tried the gpg commands in WSL2 and none of them works for me anymore šŸ˜ž I'll see if I can squeeze in some debug-time and try to find the root cause.

@carlolars that's what I'm facing right now. šŸ˜¢

lucasfcnunes commented 8 months ago

@carlolars do the following changes make it work?

https://github.com/carlolars/wsl-gap/compare/v1.0.0...main#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fc