Import Your GnuPG Keys From Backup
Written by Arnaud Lier
GNU Privacy Guard (GnuPG) is available by default on most GNU/Linux operating systems and is used to encrypt data with key pairs. In this tutorial, we'll learn how to export your GPG keys from a backup directory and import them in your new GnuPG installation.
First things first, export all keys from your backup folder:
gpg --homedir=backup/.gnupg/ -a --export-secret-keys > privatekeys.asc gpg --homedir=backup/.gnupg/ --export-ownertrust > ownertrust.txt
--homedir argument tells GPG to use another directory than the default
~/.gnupg to operate on.
Then, to import the keys in the GnuPG installation of the currently logged-in user, issue the following commands:
gpg --import privatekeys.asc gpg --import-ownertrust ownertrust.txt
In this tutorial, we've learned how to import then export GnuPG data from a backup directory! You may now want to setup commit signing with Git.