Solved

How to Create a GPG Key

Posted on 2012-03-20
2
839 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: btan
Provide an easy one stop to quickly get the relevant information on common asked question on Ransomware in Expert Exchange.
Big data transfers via information superhighways require special attention and protection. Learn more about the IT-regulations of the country where your server is located. Analyze cloud providers and their encryption systems for safe data transit. S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now