Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Create a GPG Key

Posted on 2012-03-20
2
Medium Priority
?
934 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 1000 total points
ID: 37745076
0
 
LVL 5

Assisted Solution

by:1ly4me
1ly4me earned 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Sometimes Administrators rights are not enough. These cases call for the SYSTEM account. The process in this article outlines the steps required to execute commands using the SYSTEM account.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

772 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