Quick Tutorial: How to create your gpg keys

This tutorial covers the methodology for the creation of gpg keys. For those who don't know, gpg is a free open-source implementation created in 1991. gpg, also GNU Privacy Card, uses strong encryption algorithms. This follows the asymmetric encryption rule or public-private key concept, which means you just need to send data with the public key to verify the integrity of the data.

gpg is preinstalled for some Linux distributions but if not available on your system, you can use the link for download: https://www.gnupg.org/download/

It can be used for multiple applications that include:

  • encryption of email messages to mitigate transport layer attack
  • encryption of own data to secure it from bad people
  • to check the integrity of a message
  • to check the authenticity of a message

In this tutorial, below are the steps to be followed for the creation of gpg keys:

(1) Create pair of gpg keys

You need to enter your name, email id, and passphrase for the creation of gpg keys. Remember to use a strong passphrase of at least a length of 8.

gpg --gen-keys

(2) Check whether keys got created

gpg --list-keys

(3) Check .gnupg

By using the below command, you can see public and private keyrings, gpg.conf file, trusted user db, and random seed file.

ls -l .gnupg

(4) How to export the public key to share with others

You can export a public key in the current directory by using the below command. Later, If you want to check just used the Linux cat command.

gpg --export --armor --output user1-gpg.pub


This article covers steps for how to create your gpg keys. Also, we have covered how we can export public keys in the current directory. I recommend using it next time if you are sending sensitive or secret files to your colleagues or clients.

Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

You may also like...

Leave a Reply

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