# \[NK3 mini\] gpg: selecting card failed: No such device // GPG card setup

**URL:** <https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057>\
**Category:** FIDO2 / Nitrokey 3\
**Created:** [May 9, 2023, 11:22pm UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057 "2023-05-09T23:22:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artiom-M](https://support.nitrokey.com/user_avatar/support.nitrokey.com/artiom-m/32/1418_2.png) [@Artiom-M](https://support.nitrokey.com/u/Artiom-M)\
**Post date:** [May 9, 2023, 11:22pm UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/1 "2023-05-09T23:22:10Z")

</div>

gpg doesn’t see my nitrokey,

```auto
gpg -vvv --card-status gpg: using character set 'utf-8'
gpg: enabled compatibility flags:
gpg: selecting card failed: No such device
gpg: OpenPGP card not available: No such device

```

while pscs\_scan detects it:

```auto
pcsc_scan                                                                                                                                                                                                           
PC/SC device scanner
V 1.6.2 (c) 2001-2022, Ludovic Rousseau <ludovic.rousseau@free.fr>
Using reader plug'n play mechanism
Scanning present readers...
0: Nitrokey Nitrokey 3 [CCID/ICCD Interface] 00 00
 
Wed May 10 09:03:29 2023
 Reader 0: Nitrokey Nitrokey 3 [CCID/ICCD Interface] 00 00
  Event number: 0
  Card state: Card inserted, 

```

Am I missing some setup element?

I am already using nitrokey FIDO2 in my browsers and pam with no issues, so device setup should be ok.

```auto
gpg --version                                                                                                                                                                                                       
gpg (GnuPG) 2.2.41
libgcrypt 1.10.2-unknown

```

---

<div class="post-metadata">

**Author:** ![Artiom-M](https://support.nitrokey.com/user_avatar/support.nitrokey.com/artiom-m/32/1418_2.png) [@Artiom-M](https://support.nitrokey.com/u/Artiom-M)\
**Post date:** [May 9, 2023, 11:50pm UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/2 "2023-05-09T23:50:13Z")

</div>

After reading release notes I have discovered that GPG is only supported in 1.4 firmware. After upgrade it’s now recognized!

I continue to set is up following this guide  
[https://docs.nitrokey.com/storage/windows/ecc.html?highlight=gpg](https://docs.nitrokey.com/storage/windows/ecc.html?highlight=gpg)  
however it doesn’t work:

```auto
gpg-connect-agent "SCD SETATTR KEY-ATTR --force 1 19 brainpoolP256r1" /bye                                                                                                                                    
ERR 100663383 Bad PIN <SCD>

```

I was trying my usual PIN that works for test command.

I can read in one for the screen copies:

```auto
Please note that the factory settings of the PINs are
PIN = '123456' Admin PIN = '12345678'

```

Are this different from FIDO2 PIN? How to change them? The screenprint is proposing something like

> You should change them using the command --change-pin

```auto
gpg/card> admin
Admin commands are allowed

gpg/card> command --change-pin

Invalid command (try "help")

```

---

<div class="post-metadata">

**Author:** ![Artiom-M](https://support.nitrokey.com/user_avatar/support.nitrokey.com/artiom-m/32/1418_2.png) [@Artiom-M](https://support.nitrokey.com/u/Artiom-M)\
**Post date:** [May 10, 2023, 4:21am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/3 "2023-05-10T04:21:03Z")

</div>

After some research I’ve found the change pin command.

```auto
 gpg --change-pin

```

I’ve changed both normal and Admin pin. Still I am getting error about invalid pin:

```auto
gpg-connect-agent "SCD SETATTR KEY-ATTR --force 1 19 brainpoolP256r1" /bye                                                                                                                                    
ERR 100663383 Bad PIN <SCD>

```

---

<div class="post-metadata">

**Author:** ![Artiom-M](https://support.nitrokey.com/user_avatar/support.nitrokey.com/artiom-m/32/1418_2.png) [@Artiom-M](https://support.nitrokey.com/u/Artiom-M)\
**Post date:** [May 10, 2023, 4:27am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/4 "2023-05-10T04:27:39Z")

</div>

Now I guessed that the new admin pin must be at least 8 digits. It was not mentioned in any guide/doc.  
**SETATTR** commands now passed, but with no effect:

```auto
Key attributes ...: rsa2048 rsa2048 rsa2048

```

I definitely don’t want rsa2048 keys…

---

<div class="post-metadata">

**Author:** ![tuxmaster5000](https://support.nitrokey.com/user_avatar/support.nitrokey.com/tuxmaster5000/32/1400_2.png) [@tuxmaster5000](https://support.nitrokey.com/u/tuxmaster5000)\
**Post date:** [May 10, 2023, 4:50am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/5 "2023-05-10T04:50:52Z")

</div>

I have the same problem, but with firmware 1.4.  
pcsc\_scan will detect it, but gpg not.  
pcsc\_scan:

> PC/SC device scanner  
> V 1.6.2 (c) 2001-2022, Ludovic Rousseau [ludovic.rousseau@free.fr](mailto:ludovic.rousseau@free.fr)  
> Using reader plug’n play mechanism  
> Scanning present readers…  
> 0: REINER SCT cyberJack RFID komfort (5033634424) 00 00  
> 1: Nitrokey Nitrokey 3 [CCID/ICCD Interface] 00 00
> 
> Wed May 10 06:49:33 2023  
> Reader 0: REINER SCT cyberJack RFID komfort (5033634424) 00 00  
> Event number: 0  
> Card state: Card removed,  
> Reader 1: Nitrokey Nitrokey 3 [CCID/ICCD Interface] 00 00  
> Event number: 0  
> Card state: Card inserted, Shared Mode,  
> ATR: 3B 8F 01 80 5D 4E 69 74 72 6F 6B 65 79 00 00 00 00 00 6A

gpg -vvv --card-status:

```auto
 LANG=C gpg -vvv --card-status
gpg: using character set 'utf-8'
gpg: selecting card failed: No such device
gpg: OpenPGP card not available: No such device

```

GPG:

> LANG=C gpg --version  
> gpg (GnuPG) 2.3.8  
> libgcrypt 1.10.1-unknown  
> Copyright (C) 2021 Free Software Foundation, Inc.  
> License GNU GPL-3.0-or-later [https://gnu.org/licenses/gpl.html](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/XXXXX/.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

---

<div class="post-metadata">

**Author:** ![Artiom-M](https://support.nitrokey.com/user_avatar/support.nitrokey.com/artiom-m/32/1418_2.png) [@Artiom-M](https://support.nitrokey.com/u/Artiom-M)\
**Post date:** [May 10, 2023, 6:01am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/6 "2023-05-10T06:01:56Z")

</div>

I think I have found all answers for my questions. The remaining part about keys management is here

> <https://github.com/Nitrokey/opcard-rs/blob/v1.0.0/USAGE.md>

Hope it will all go to a Nitrokey 3 guide on the main documentation site 😉

---

<div class="post-metadata">

**Author:** ![robin-nitrokey](https://support.nitrokey.com/letter_avatar_proxy/v4/letter/r/b19c9b/32.png) [@robin-nitrokey](https://support.nitrokey.com/u/robin-nitrokey)\
**Post date:** [May 10, 2023, 9:04am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/7 "2023-05-10T09:04:09Z")

</div>

Per default, gnupg uses its own CCID driver, not pcscd. If the card is detected by pcscd, gnupg can no longer access it. There are two solutions:

1. Instruct GnuPG to use pcscd by adding `disable-ccid` to `~/.gnupg/scdaemon.conf` and restart scdaemon with `gpg-connect-agent 'SCD KILLSCD' /bye`
2. Stop pcscd and re-connect the device (make sure that pcscd is not activated again by a socket or similar)

See this guide for more information: [Ludovic Rousseau's blog: GnuPG and PC/SC conflicts](https://ludovicrousseau.blogspot.com/2019/06/gnupg-and-pcsc-conflicts.html)

---

<div class="post-metadata">

**Author:** ![tuxmaster5000](https://support.nitrokey.com/user_avatar/support.nitrokey.com/tuxmaster5000/32/1400_2.png) [@tuxmaster5000](https://support.nitrokey.com/u/tuxmaster5000)\
**Post date:** [May 10, 2023, 9:35am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/8 "2023-05-10T09:35:27Z")

</div>

Hm, this will not really fix it, because now gpg will take an exclusive lock to the NK3.  
So only gpg can use it and no other applications. ☹  
pcsc\_scan:

```auto
Reader 1: Nitrokey Nitrokey 3 [CCID/ICCD Interface] 00 00
  Event number: 0
  Card state: Card inserted, Exclusive Mode, 
  ATR: 3B 8F 01 80 5D 4E 69 74 72 6F 6B 65 79 00 00 00 00 00 6A

```

pkcs11-tool --list-slots:

```auto
Available slots:
Slot 0 (0x0): REINER SCT cyberJack RFID komfort (5033634424) 00 00
  (empty)
Slot 1 (0x4): (GetSlotInfo failed, CKR_DEVICE_ERROR)

```

---

<div class="post-metadata">

**Author:** ![robin-nitrokey](https://support.nitrokey.com/letter_avatar_proxy/v4/letter/r/b19c9b/32.png) [@robin-nitrokey](https://support.nitrokey.com/u/robin-nitrokey)\
**Post date:** [May 10, 2023, 11:16am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/9 "2023-05-10T11:16:44Z")

</div>

Unfortunately, this is a limitation of GnuPG/scdaemon. With more recent releases, you can try to use the `--pcsc-shared` option for scdaemon so that it no longer requires an exclusive lock. But it still caches some card state, so using it with other applications may cause problems.

An alternative approach could be to use Sequoia PGP and their [openpgp-card tools](https://gitlab.com/openpgp-card/openpgp-card) instead which does not require exclusive access to the card.

---

<div class="post-metadata">

**Author:** ![beneth](https://support.nitrokey.com/letter_avatar_proxy/v4/letter/b/a87d85/32.png) [@beneth](https://support.nitrokey.com/u/beneth)\
**Post date:** [September 19, 2024, 2:36pm UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/10 "2024-09-19T14:36:12Z")

</div>

Maybe this is not the same subject, but on Archlinux today, I was not able to use anymore my Nitrokey 3c NFC (20a0:42b2).  
In contrast my Nitrokey Pro (20a0:4108) was working fine.

By opening the udev rules, I see that Nitrokey 3 do not set the :

`ENV{ID_SMARTCARD_READER}="1", ENV{ID_SMARTCARD_READER_DRIVER}="gnupg"`

So I add this to the rules for my Nitrokey and its working again.

Why rules are different than a nitrokey pro 2 for example ? I use only gnupg for using nitrokey smartcard.

---

<div class="post-metadata">

**Author:** ![sosthene-nitrokey](https://support.nitrokey.com/user_avatar/support.nitrokey.com/sosthene-nitrokey/32/1374_2.png) [@sosthene-nitrokey](https://support.nitrokey.com/u/sosthene-nitrokey)\
**Post date:** [September 20, 2024, 8:11am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/11 "2024-09-20T08:11:14Z")

</div>

Hi,

What is the gpg config you are using? You can find it at `~/.gnupg/gpg-agent.conf`, `~/.gnupg/scdaemon.conf`

Best,  
Sosthène

---

<div class="post-metadata">

**Author:** ![beneth](https://support.nitrokey.com/letter_avatar_proxy/v4/letter/b/a87d85/32.png) [@beneth](https://support.nitrokey.com/u/beneth)\
**Post date:** [September 20, 2024, 8:39am UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/12 "2024-09-20T08:39:47Z")

</div>

Hello,

~/.gnupg/gpg-agent.conf :

```auto
# pinentry conf
default-cache-ttl 300
max-cache-ttl 7200
enable-ssh-support
allow-emacs-pinentry

```

And ~/.gnupg/scdaemon.conf :

```auto
pcsc-driver /usr/lib/libpcsclite.so

```

Please note that **without** udev rules hack, I have the following log when trying to use my key with gpg (gpg --card-status) :

```auto
gpg-agent[6207]: scdaemon[6207]: ccid open error: skip
gpg-agent[6207]: scdaemon[6207]: check permission of USB device at Bus 003 Device 034

```

Thx for your help,

---

<div class="post-metadata">

**Author:** ![sosthene-nitrokey](https://support.nitrokey.com/user_avatar/support.nitrokey.com/sosthene-nitrokey/32/1374_2.png) [@sosthene-nitrokey](https://support.nitrokey.com/u/sosthene-nitrokey)\
**Post date:** [September 20, 2024, 2:38pm UTC](https://support.nitrokey.com/t/nk3-mini-gpg-selecting-card-failed-no-such-device-gpg-card-setup/5057/13 "2024-09-20T14:38:01Z")

</div>

There is another way to get this to work, by using `pcscd`.

Replace `pcsc-driver /usr/lib/libpcsclite.so` by `disable-ccid` and using the `pcscd` service: `systemctl enable pcscd`.
