How To: Import your GnuPG Keys from a Backup
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.
Export data
First things first, export all keys from your backup
directory:
gpg --homedir=backup/.gnupg/ -a --export-secret-keys > privatekeys.asc
gpg --homedir=backup/.gnupg/ --export-ownertrust > ownertrust.txt
The --homedir
argument tells GPG to use another directory than the default ~/.gnupg
to
operate
on.
Import directory
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