Recover personal PGP key from old home

If you have your whole old home directory backed up, all you need to do is copy the old ~/.gnupg/ folder to your new home.

Though it should be noted that this isn't really the best way to back up and restore a key. It has the draw back of over-writing the gpg keyrings on the target system. If you've imported public keys or created new keys, this isn't the ideal solution.

Typically, you should save your public and private keys using:

gpg -ao mypub.key --export <MY_KEY_ID>
gpg -ao myprivate.key --export-secret-keys <MY_KEY_ID>

Then import them on the new system with:

gpg --import myprivate.key
gpg --import mypub.key

This way they are just added to the keyring on the target system.


Navigate to the ./gnupg of your old home directory

then

gpg --import pubring.gpg
gpg --import secring.gpg

import anything else in there you might need.

Tags:

Gnupg

Pgp