I want to import my old gpg2 secret keyring from a backup. I only have my old .gnupg directory.

But all files in this folder are unrecognized by gpg2, which says "No valid OpenPGP data found" when I try to --import them.

How can I import my old secret keys ?


Solved it by replacing my new .gnupg directory by the old one, exporting the keys in an importable format, then restoring my new .gnupg and importing the keys :

mv ~/.gnupg ~/.new_gnupg
cp -r old_backup/.gnupg ~
gpg2 --export-secret-keys > sec.gpg
rm -r ~/.gnupg
mv ~/.new_gnupg ~/.gnupg
gpg2 --import sec.gpg

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.