Solved

How to Create a GPG Key

Posted on 2012-03-20
2
882 Views
Last Modified: 2012-03-26
Step by step, how do i create a free GPG key
0
Comment
Question by:deklinm
2 Comments
 
LVL 3

Accepted Solution

by:
IT-Shrek earned 250 total points
ID: 37745076
0
 
LVL 5

Assisted Solution

by:1ly4me
1ly4me earned 250 total points
ID: 37747015
You would need at least two systems to setup GPG key.
1. Main system (to hold private key)
2. Remote system (to have public key)

In the main system,
#gpg2 --gen-key
(The attached image shows the output of the above command)
You need enter some password for your private key.
It takes some time to generate key pair, so you can do some other work in the mean time.
To list keys,
#gpg2 --list-key
/root/.gnupg/pubring.gpg
------------------------
pub   2048R/91BE71BA 2012-03-21 [expires: 2012-05-20]
uid                  MyName (MY GPG Key Pair) <myname@exampl.com>
sub   2048R/3EF035BA 2012-03-21 [expires: 2012-05-20]

Now you can send the public key to remote system. First export the key and send
# gpg2 --export MyName > gpg.pub
# scp gpg.pub remote.IP.addr:
I used scp command to send, you can send public key via email, USB or any method.

On the remote system, run the following command
#gpg2 --list-key
If the system doesn't have any previous gpg keys, it should return empty output
Then import the exported key from the main system
#gpg2 --import gpg.pup
gpg: key 91BE71BA: public key "MyName (MY GPG Key Pair) <myname@exampl.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
#gpg2 --list-key
It will now list the imported key.
Next part is encrypting the file with public key,
#gpg2 --out test_encrypt.txt --recipient 'MyName' --encrypt test.txt
here the file test.txt is encrypted with public key of user MyName and the encrypted file will be named as test_encrypt.txt.
Then send that encrypted file to main system.
#scp test_encrypt.txt main.system.IP.addr:
Back on the main system,
decrypt the file with private key of user MyName,
#gpg2 --out mysecret.txt --decrypt test_encrypt.txt
You have to enter password for private key that you have setted up earlier.
(This decrypts the file test_encrypt.txt to file mysecret.txt)
Final review is you use only 4 commands to setup  GPG key pair
Main system
#gpg2 --gen-key
#gpg2 --list-key
#gpg2 --export MyName > gpg.pub
#scp gpg.pub remote.IP.addr:

Remote system
#gpg2 --import gpg.pup
#gpg2 --list-key
#gpg2 --out test_encrypt.txt --recipient 'MyName' --encrypt test.txt
#scp test_encrypt.txt main.system.IP.addr:

Main system
#gpg2 --out mysecret.txt --decrypt test_encrypt.txt

Open in new window

gpg.JPG
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article outlines the process to identify and resolve account lockout in an Active Directory environment.
Knowing where your website is hosted is as important as the features you receive, the monthly fee, and the support you receive. Due diligence should be done when choosing your next hosting provider.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question