
GnuPG sometimes gets confused about which SmartCard a subkey is on, and refuses to use it from the currently-available card.
tl;dr: Here’s a quick script to fix the issue.
$ export SUBKEYID=...
$ KEYGRIP=$(gpg --with-keygrip -k ${SUBKEYID} | sed -n "/${SUBKEYID}/,/$/{s/ *Keygrip = //p}" )
$ rm -i ~/.gnupg/private-keys-v1.d/${KEYGRIP}.key
$ gpg --card-status # recreate the stub from the daily-use key
Continue reading