Page MenuHome GnuPG

Export keys to secure card failure: gpg: KEYTOCARD failed: Unusable secret key
Open, NormalPublic


I have deleted any PGP key on my secure card (Yubikey 5), and now I want to export the keys again.
However this fails with error message:
gpg: KEYTOCARD failed: Unusable secret key

So I deleted directory .gnupg to start all over again. Executing command

gpg -k

created the directory again.
Then I imported the all keys (incl. private key) from a backup.

However, the subkeys are still marked as stub, and I think this is causing the error when I try to export the keys to secure card.

Please advise how to remove the stub.



Event Timeline

Do you mean you want to copy a backup key created while generating the keys for the card onto a new card?

In any case you need you public key because they are not stored on the card. You may create a new key using the private keys stored on the card; it is quite some work though.

gniibe added a subscriber: gniibe.

Did you remove .gnupg entirely? Secret keys are stored in .gnupg/private-keys-v1.d. If it remained, you didn't import your secret keys.
If it was the case, I'd like to merge this report to T3391: cannot import subkey that was once marked to be on a card.

gniibe raised the priority of this task from Low to Normal.