Go Back   Linux Forums by TotalPenguin! Get linux Help! > Linux > Tutorials, Guides and Tips

Tutorials, Guides and Tips Member submitted guides, tips, tricks and howtos.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-20-2008, 02:21 PM
Jordan's Avatar
Administrator
 
Join Date: Nov 2006
Posts: 507
Jordan is on a distinguished road
Default GPG (GnuPG) Exporting/Importing Keys Tutorial

I've been working with GPG a lot lately and the need arose to export keys from one machine and import them on another machine. I couldn't find any good, well written articles for this so I decided to write one myself. I'll show you how to export first and then import the key on another machine.

Exporting
To export a key you'll need two keys, the public and secret key. To begin export the public key:

Code:
# gpg --output <filename> --export <keyname>
If I wanted to export the key "Jordan" to a file named myPublicKey I would execute this command:

Code:
gpg --output myPublicKey --export Jordan
After running this command you should be brought back to the prompt but a new file will exist named myPublicKey. Now we need to export the secret key:

Code:
gpg --output <filename> --export-secret-keys <keyname>
If you wanted to export to mySecretKey from the user Jordan you would execute this command:

Code:
gpg --output mySecretKey --export-secret-keys Jordan
Now that you have both keys exported we need to import the keys on a different system.

Importing
After you have moved the keys to a new system importing is fairly easy. Let's start by importing the public key. You issue the command

Code:
gpg --import <filename>
In our case we want to import myPublicKey so the command would be:

Code:
gpg --import myPublicKey
If this is your first import you will see output with WARNINGs:

Code:
gpg: directory `/jordan/.gnupg' created
gpg: new configuration file `/jordan/.gnupg/gpg.conf' created
gpg: WARNING: options in `/jordan/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/jordan/.gnupg/secring.gpg' created
gpg: keyring `/jordan/.gnupg/pubring.gpg' created
gpg: /jordan/.gnupg/trustdb.gpg: trustdb created
gpg: key EC6271C0: public key "Jordan (Jordan) <my@email.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
If this isn't the first time you've ran GPG (generated a key or imported a key) you will see output similar to this:

Code:
gpg: key EC6271C0: "Jordan (Jordan) <my@email.com>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1
Now we need to import our secret key. You import it using the same command above:

Code:
gpg --import <filename>
We will import our secret key by executing:
Code:
gpg --import mySecretKey
You should see output similar to:

Code:
gpg: key EC6271C0: secret key imported
gpg: key EC6271C0: "Jordan (Jordan) <no@email.com>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1
gpg:       secret keys read: 1
gpg:   secret keys imported: 1
Testing
You can test by encrypting a file on System A and moving it to System B. Use GPG to decrypt that file on System B. You should be asked to enter your passphrase and your file should look the same as on System A.

If you have any questions don't hesitate to ask!
Reply With Quote

Sponsored Links
Reply

Tags
encryption, exporting, gnupg, importing, keys, private, public

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding keyboard keys in Linux TotalPenguin Tutorials, Guides and Tips 1 08-19-2008 03:33 PM
GPG/GnuPG Encyrption Tutorial Tor Tutorials, Guides and Tips 0 08-15-2008 03:41 PM
What makes a top tutorial MHJ Tutorials, Guides and Tips 5 06-25-2008 03:31 PM
SSH Keys C3P0 Linux Networking 2 05-27-2007 11:07 PM


All times are GMT. The time now is 11:26 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.