How to : Export/Import GPG key

Hi there,
Today I made a clean install of Fedora 18 in my laptop. Previously I used Ubuntu 12.10, there I used a GPG key and I dont wanna make new one. So before install Fedora 18 I export my key pair (public and secret). To export key pair you need to do the followings,

gpg --list-keys

which will give output something like,

pub 1024D/123ABC89 2012-12-08
uid Tapan Kumer Das

Here 123ABC89 is your ID.

gpg –output mygpgkey_pub.gpg –armor –export 123ABC89
gpg –output mygpgkey_sec.gpg –armor –export-secret-key 123ABC89

Now backup that mygpgkey_pub.gpg and mygpgkey_sec.gpg files.

After install fresh OS you need to import this key pair to that OS with following,

gpg –import ~/mygpgkey_pub.gpg
gpg –allow-secret-key-import –import ~/mygpgkey_sec.gpg

now use,

gpg --list-key

bingo you got your exported key pair import in new OS. 🙂

Now if you like to add this key to git global configuration do the following,

git config --global user.signingkey 123ABC89

Cheers friends. Enjoy the GPG key…

(Visited 69 times, 1 visits today)

Leave a comment

Your email address will not be published. Required fields are marked *