[38;5;244m┌─[0m [38;5;40mroot@joaocosta:~#[0m [38;5;245mcat posts/18.md[0m [38;5;244m───────────────────────────────────────────[0m

[38;5;40m#[0m [1mPSA: YubiKey PGP smart card reader in Linux[0m
[38;5;245mpublished 2025-10-01 · 1 min read · https://joaocosta.dev/blog/18[0m

Up until now, I've storing passkeys in my Bitwarden (Vaultwarden) instance. I
like them, so I bought a YubiKey.

[38;5;38m##[0m [1mPGP Smart Card[0m

In essence, you can use your PGP in your YubiKey and sign/encrypt stuff from it.
It's a nice way to use your key in multiple devices. The Arch Wiki has a [38;5;40mnice
guide about it[0m [38;5;244m(https://wiki.archlinux.org/title/YubiKey#OpenPGP_smartcards)[0m.

After generating new PGP keys and storing them in my YubiKey, I was having
trouble using the smart card feature. My YubiKey wasn't consistently detected by
gpg: running [38;5;38mgpg --card-status[0m would throw out an error saying there weren't any
smart cards detected.

[38;5;38m##[0m [1mSolution[0m

Turns out that YubiKeys have 2 CCID smartcard applications, PIV and OpenPGP, but
only one can be active at a time. For some reason, the YubiKey was constantly
switching to PIV mode, which made gpg fail to detect the smart card. The
solution was to disable the PIV application in the settings of gpg:

[38;5;244m┄────────────────────────────────────────────────────────────────────────── sh [0m
[38;5;245m│[0m # ~/.gnupg/scdaemon.conf
[38;5;245m│[0m pcsc-driver /usr/lib/libpcsclite.so
[38;5;245m│[0m disable-ccid
[38;5;245m│[0m pcsc-shared
[38;5;245m│[0m # the important line:
[38;5;245m│[0m disable-application piv
[38;5;244m┄──────────────────────────────────────────────────────────────────────────────[0m

I had to create this [38;5;38mscdaemon.conf[0m file, as it didn't exist for me.

[38;5;38m##[0m [1mConclusion[0m

To be honest, this problem seems to stem from me not understanding everything
that is going on, but it was hard for me to find the solution anywhere. Maybe
this post saves time to someone.

Stay safe :P

[38;5;244m└─[0m [38;5;40m→[0m view online: [38;5;40mhttps://joaocosta.dev/blog/18[0m
