I have 2 YubiKeys and want one of them to be a backup. So let's say I generated a key
$KEY in my computer with an encryption subkey. I need to export the secret keys, because when moving them to the card they disappear, and then reimport them.
So I export them with
gpg2 -a -o secmain.asc --export-secret-key --armor $KEY gpg2 -a -o secsub.asc --export-secret-subkeys --armor $KEY
move them to the card, and then re-import them with:
gpg2 --import secmain.asc gpg2 --import secsub.asc
I would expect this to work (as this is what was in the tutorial I read), but on the second import GPG tells me that the key was not changed, so I don't have my encryption key back. After searching a bit I found out about the
--export-secret-keys option, which I assumed would export main and all sub keys in one package, but on import encryption subkey is still missing.
How can this be done?
After further discussions, I tried to generate default keys and those I can correctly import/export. Then I the keys with my preferred settings manually and they also imported well. So it turns out this issue only occurs when I generate a key using this command:
gpg2 --batch --gen-key <<EOF Key-Type: EdDSA Key-Curve: ed25519 Key-Usage: sign Subkey-Type: ECC Subkey-Curve: Ed25519 Subkey-Usage: encrypt Name-Real: My Name Name-Comment: uname Name-Email: email@example.com Expire-Date: 0 EOF
What gives? What's wrong here, and if it is, why isn't there a warning?