Many lives ago, I created a GPG key to sign the Ubuntu Code of Conduct on Launchpad. I haven't really used it since. Some time later, I backed up my home and started fresh.

That was all back in 2009. I still have the backup but now I'm starting to play around with Quickly and upload things to Launchpad, I could really do with having my PGP key back.

I don't really know how the key is organised or where it's stored, but I'd like to recover my old key rather than generate a new one. Any idea where to start?


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.

  • 1
    Please be aware that gpg does NOT hang here, it should ask for a passphrase for each key.
    – pbies
    Dec 8 '18 at 2:03

Navigate to the ./gnupg of your old home directory


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

import anything else in there you might need.


I had the same issue.

And I solved it without losing my newly generated keys by moving .key files from old to new ~/.gnupg/private-keys-v1.d folder and restarting gnupg.

This only works with GnuPG 2.1 or above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.