Step 1: Backup your gpg key

First list your keys first

# gpg --list-keys

/root/.gnupg/pubring.gpg
————————
pub   1024D/EE6E8046 2009-02-20
uid                 Bill Till (My GPG key) <test@abc.com>
sub   2048g/AE3B1BD4 2009-02-20

Select the KeyID which belogs to you. In this case it is EE6E8046.

To backup your Public key give the following command:

#  gpg -ao mypub.key --export EE6E8046

This will create a file called “mypub.key”

To backup your Private key give the following command:

#  gpg -ao myprivate.key--export-secret-keys EE6E8046

This will create a file called “myprivate.key”

Now store these two files (mypub.key and mypub.key) on a floppy disk, CD or USB drive and put it away to some secure and safe place.

Step 2: Restore your gpg key

To restore the keys give the following commands:

# gpg --import myprivate.key

gpg: key EE6E8046: secret key imported
gpg: key EE6E8046: public key “Bill Till (My GPG key) <test@abc.com>” imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg:       secret keys read: 1
gpg:   secret keys imported: 1

# gpg --import mypub.key

gpg: key EE6E8046: “Bill Till (My GPG key) <test@abc.com>” not changed
gpg: Total number processed: 1
gpg:              unchanged: 1

# gpg --list-keys

/root/.gnupg/pubring.gpg
————————
pub   1024D/EE6E8046 2009-02-20
uid                  Bill Till (My GPG key) <test@abc.com>
sub   2048g/AE3B1BD4 2009-02-20

Advertisements