Fixing GnuPG

Yesterday my GnuPG went sideways with the following message:

GPG Error message

I ended up trashing my whole installation and reimporting everything before redoing my configuration. The first step is to create a backup of all your keys, in armored base64 format:

gpg --armor --export > pgp-public-keys.asc
gpg --armor --export-secret-keys > pgp-private-keys.asc
gpg --export-ownertrust > pgp-ownertrust.asc

I created a backup just to be sure (YMMV, but I like to keep it safe), and then shred and remove it.

tar cvfz gpg.tgz .gnupg
find .gnupg -type f -exec gshred {} \;
rm -Rf .gnupg

Now we can reimport everything into the new installation:

gpg --import pgp-public-keys.asc
gpg --import pgp-private-keys.asc
gpg --import-ownertrust pgp-ownertrust.asc

I will write an explanatory post for my gpg.conf later on.