I re-imported all keys into a clean GnuPG directory to remove legacy from previous versions. (migration issues from v1 to v2)
gpg2 -a --export >mypubkeys.asc
gpg2 -a --export-secret-keys >myprivatekeys.asc
gpg2 --export-ownertrust >otrust.txt
mv .gnupg .gnupg.old
gpg2 --import myprivatekeys.asc
gpg2 --import mypubkeys.asc
gpg2 --import-ownertrust otrust.txt
The export and subsequent import were successful.
The keys are all there.
When comparing, however, it is noticeable that some .key files in private-keys-v1.d are gone.
How can I view these files and see the uids?
Are these legacy issues from “test keys” that haven’t been completely erased?
I don’t know it there is a way to directly view the content of .key files with GnuPG. But since you created a backup you could compare which key files are missing in your new .gnupg/private-keys-v1.d folder. Than you could delete all key files in this folder and just copy the missing key files from your backup into this folder. Finally, you can run “gpg --list-secret-keys” to see IDs etc.
btw for list secret keys you might want to add --with-keygrip as parameter.
The keygrip is the filename of the file in private-keys-v1.d so you can confirm that you have all private keys you need.
You can open the key files in an editor (e.g. Notepad) to view the contents. Usually there are two secret keys (because of the encryption subkey) for a single OpenPGP certificate.