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


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.


werner added a subscriber: werner.Aug 10 2020, 6:28 PM

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.