What is GPG and why you should start using it (2024)

Introduction

Once a wise man said, “If you are real nerd, sign your git commits with GPG ↗️”. I am not sure if that wise or not but I am sure that GPG is a powerful tool that allows you to encrypt and sign your data and communications.

In this post, I will explain what GPG is and why and how you can start using it in your workflows.

What is GPG?

GPG stands for GNU Privacy Guard ↗️. It is a free and open-source implementation of the OpenPGP standard. GPG is a tool that allows you to encrypt and sign your data and communications. It is widely used to secure email communication, software packages, and other sensitive data.

GPG uses a combination of symmetric-key cryptography and public-key cryptography to secure your data. Symmetric-key cryptography is used to encrypt and decrypt data, while public-key cryptography is used to securely exchange encryption keys.

Where is GPG used?

If you download software packages from the internet, you may have noticed that some of them are signed with a GPG key. This is done to ensure that the software package has not been tampered with during the download process.

By verifying the GPG signature of the software package, you can be sure that it has not been modified by a malicious actor. The package authors use their GPG key to sign the software package, and you can use their public key to verify the signature.

The more popular a project is the more likely it is to be targeted by malicious actors. For example, the Nodejs project explicitly specifies how to verify the GPG signature of the Nodejs binaries in their readme ↗️

What is GPG and why you should start using it (1)

Just like signing packages, you can also sign your git commits with GPG. This is done to ensure that the commit has been made by you and not by someone who just used your name and email address (And yes this is easily possible for anyone to do).

When you sign your commits with GPG, you are adding an extra layer of security to your git repository. This is how your commits look like when you sign them with GPG

What is GPG and why you should start using it (2)

Now if someone tries to impersonate me and make a commit, you can easily verify if the commit was made by me or not based on the GPG signature.

How to create GPG keys?

GPG as a tool is by default available on most Linux distributions. You can install it using your package manager. For example, on Debian, you can install GPG (specifically version 2) using the following command:

sudo apt-get install gnupg2

I have aliases gpg to gpg2 in my shell so I can use gpg instead of gpg2. But feel free to use gpg2 if you want to be explicit.

Once you have installed GPG, we can generate key with ED25519 algorithm which is considered to be more secure than RSA. You can generate a new GPG key using the following command:

gpg --full-generate-key

This will ask you which key do you want to create, use the option 9 which is ECC sign and encrypt.

Please select what kind of key you want:

(1) RSA and RSA

(2) DSA and Elgamal

(3) DSA (sign only)

(4) RSA (sign only)

(9) ECC (sign and encrypt) *default*

(10) ECC (sign only)

(14) Existing key from card

Your selection? 9

Once you select this, it will ask you to choose the elliptical curve. Choose the option 1 which is ED25519.

Please select which elliptic curve you want:

(1) Curve 25519 *default*

(4) NIST P-384

(6) Brainpool P-256

Your selection? 1

After this, it will ask for the validity of the key, now this depends for you, you can either opt for never expire or you can set the expiry date for the key. Choose the option which suits you. The default value is “0” which means the key will never expire.

Please specify how long the key should be valid.

0 = key does not expire

<n> = key expires in n days

<n>w = key expires in n weeks

<n>m = key expires in n months

<n>y = key expires in n years

Key is valid for? (0)

Now we have decided what type of the key we want, so next steps are to enter your name, email address and a comment. The comment is optional, you can leave it empty. This will help you to identify the key in the future.

GnuPG needs to construct a user ID to identify your key.

Real name: Your Name

Email address: [emailprotected]

Comment: My GPG Key

"Your Name (My GPG Key) <[emailprotected]>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O

Once you verify and proceed with the key generation, it will ask you to enter a passphrase. This passphrase will be used to unlock your private key. Make sure you remember this passphrase and save it somewhere safe.

Once your keys are generated, you can list them using the following command:

gpg --list-secret-keys --keyid-format LONG

This will list all the keys you have on your system. You can see the key ID of the key you just generated. Once the key is generated, let’s trust the key and mark it as ultimate trust. We will do this by using the following command:

gpg --edit-key [emailprotected]

Replace [emailprotected] with the actual email address that you used to generate the key. This will open the GPG key editor where a prompt would be available, type trust and press enter. This will ask you to select the trust level, choose the option 5 which is ultimate trust.

gpg> trust

sec ed25519/G8F0B5B0488V820F

created: 2023-10-30 expires: never usage: SC

trust: ultimate validity: ultimate

ssb cv25519/F4B8A4AACE6C7CB7

created: 2023-10-30 expires: never usage: E

[ultimate] (1). Your Name (My GPG Key) <[emailprotected]>

Please decide how far you trust this user to correctly verify other users' keys

(by looking at passports, checking fingerprints from different sources, etc.)

1 = I don't know or won't say

2 = I do NOT trust

3 = I trust marginally

4 = I trust fully

5 = I trust ultimately

m = back to the main menu

Your decision? 5

Do you really want to set this key to ultimate trust? (y/N) y

Once this is done, type quit to exit out of the GPG prompt. Now try the listing your keys again with:

gpg --list-secret-keys --keyid-format LONG

You will see the trust level of the key is now ultimate.

How to use GPG with Git?

Now that we have generated the GPG key, let’s configure git to use this key to sign the commits. You can do this by setting the user.signingkey configuration in git. You can set this configuration using the following command:

git config --global user.signingkey G8F0B5B0488V820F

Use the key ID that you generated in the previous step. Once this is done, you can sign your commits using the -S flag with the git commit command. For example:

git commit -S -m "My signed commit"

This will sign the commit with your GPG key. You can verify the signature of the commit using the git verify-commit command. For example:

git verify-commit HEAD

This will show you the details of the commit and the GPG signature. You can also see the GPG signature in the commit message when you view the commit history. For example:

git log --show-signature

With this you should be able to see the GPG signature in the commit history. This will help you to verify the authenticity of the commits in your git repository.

Conclusion

GPG is a powerful tool that allows you to encrypt and sign your data and communications. It is widely used to secure email communication, software packages, and other sensitive data. I talked a bit about GPG and then showed how you can create a new GPG key with ED25519 algorithm, trust the key and mark it as ultimate trust. I also showed how you can use GPG with git to sign your commits.

In the next blog, I will share with you about how I use GPG in my daily workflows, so keep an eye for that if you are interested to learn more about GPG and its use cases.

As always, If you have any questions or suggestions, feel free to reach out to me on Twitter ↗️ / Reddit ↗️.

See you in the next one. 👋

What is GPG and why you should start using it (2024)

FAQs

What is GPG and why you should start using it? ›

GPG is a tool that allows you to encrypt and sign your data and communications. It is widely used to secure email communication, software packages, and other sensitive data. GPG uses a combination of symmetric-key cryptography and public-key cryptography to secure your data.

What is GPG and why is it used? ›

The GNU Privacy Guard

GnuPG allows you to encrypt and sign your data and communications; it features a versatile key management system, along with access modules for all kinds of public key directories. GnuPG, also known as GPG, is a command line tool with features for easy integration with other applications.

Why do I need GPG? ›

GPG can use both symmetric and asymmetric encryption to encrypt, decrypt, and sign messages or data using public and private keys. Encryption is an excellent method to ensure that secure communications occur between two parties, easily sharing sensitive data across an insecure network.

What is GPG explained? ›

GPG basics. The GNU Privacy Guard, also known as GnuPG or simply GPG, is a popular open source OpenPGP (RFC4880) implementation. The system is widely trusted for securing integrity and confidentiality of internet communications through various cryptographic methods.

What are the disadvantages of GPG? ›

Difficult User Experience: Many reviewers find the user experience of GnuPG confusing or cryptic, either due to its interface design or because cryptography is naturally complex, making it difficult for most users.

Should I use PGP or GPG? ›

PGP and GPG provide secure encryption and authentication, with PGP being proprietary and GPG open-source and free. Following Phil Zimmermann's PGP, GPG emerged as an OpenPGP-compliant free version. Your preference between PGP and GPG depends on your willingness to pay for licensing and support services.

Should I use GPG or SSH? ›

If your goal is to protect sensitive data from unauthorized access, then GPG encryption could be the more preferable option. However, if you need to authenticate users and establish secure channels between different systems, SSH-based authentication would be a better choice.

Are GPG keys secure? ›

With its combination of asymmetric (Public + Private Key) cryptography and symmetric (Secret Key) cryptology, GPG encryption provides a high level of data protection.

How do you use the GPG tool? ›

Encrypt & Decrypt
  1. To encrypt a file, right-click it, navigate to the “Services” sub-menu and click “OpenPGP: Encrypt File”.
  2. You will now see a dialog for selecting encryption options. ...
  3. To decrypt a file that has been sent to you, right-click the file and select “OpenPGP: Decrypt File” from the “Services” menu.

Why install GPG key? ›

Clients use GPG keys to check the authenticity of software packages before they are installed. Only trusted software can be installed on clients.

What algorithms does GPG use? ›

Ciphers (Symmetric Encryption Algorithms)
  • AES-128.
  • AES-192.
  • AES-256 (default)
  • Blowfish.
  • CAST5.
  • DES.
  • IDEA.
  • Triple DES(DESede)

What is the GPG secret key? ›

GnuPG uses public-key cryptography so that users may communicate securely. In a public-key system, each user has a pair of keys consisting of a private key and a public key. A user's private key is kept secret; it need never be revealed. The public key may be given to anyone with whom the user wants to communicate.

What is GPG in networking? ›

GPG (GNU Privacy Guard) is a free software tool that provides cryptographic privacy and authentication for data communication. It is a part of the GNU Project and serves as an open-source implementation of the OpenPGP standard, enabling users to encrypt and sign their data and communications.

Does GPG compress data? ›

By default GPG will compress the content of encrypted message, which contains a variable part in addition to the payload. Therefore the size of the encrypted message may vary even when the payload does not change.

Is GPG encrypted? ›

GPG will create an encrypted version of the file you specified; the encrypted file will have a . gpg file extension (such as my_file. gpg ). After confirming the encrypted version has been created, you can delete the original unencrypted file.

What is a GPG application? ›

GNU Privacy Guard (GnuPG or GPG) is a free-software replacement for Symantec's cryptographic software suite PGP. The software is compliant with RFC 4880, the IETF standards-track specification of OpenPGP. Modern versions of PGP are interoperable with GnuPG and other OpenPGP v4-compliant systems.

What does GPG command do? ›

gpg caches the passphrase used for symmetric encryption so that a decrypt operation may not require that the user needs to enter the passphrase. The option --no-symkey-cache can be used to disable this feature. Store only (make a simple literal data packet).

Why use GPG key in Linux? ›

GPG, or GNU Privacy Guard, is a public key cryptography implementation. This allows for the secure transmission of information between parties and can be used to verify that the origin of a message is genuine.

Top Articles
Minecraft Mental Health Benefits
TurboTax Review 2024: The Gold Standard of Online Tax Software
Bild Poster Ikea
Avonlea Havanese
Usborne Links
Apex Rank Leaderboard
Gameplay Clarkston
CHESAPEAKE WV :: Topix, Craigslist Replacement
World of White Sturgeon Caviar: Origins, Taste & Culinary Uses
W303 Tarkov
Goldsboro Daily News Obituaries
What Is A Good Estimate For 380 Of 60
Sarpian Cat
Kinkos Whittier
Jvid Rina Sauce
Used Drum Kits Ebay
7 Fly Traps For Effective Pest Control
boohoo group plc Stock (BOO) - Quote London S.E.- MarketScreener
Uktulut Pier Ritual Site
Las 12 mejores subastas de carros en Los Ángeles, California - Gossip Vehiculos
Hanger Clinic/Billpay
Dover Nh Power Outage
Heart Ring Worth Aj
Brazos Valley Busted Newspaper
Parc Soleil Drowning
Gran Turismo Showtimes Near Marcus Renaissance Cinema
Www Va Lottery Com Result
Temu Seat Covers
Taylored Services Hardeeville Sc
Rainfall Map Oklahoma
031515 828
Package Store Open Near Me Open Now
Angel del Villar Net Worth | Wife
Newsday Brains Only
AsROck Q1900B ITX und Ramverträglichkeit
Craigslist Georgia Homes For Sale By Owner
Finland’s Satanic Warmaster’s Werwolf Discusses His Projects
Fapello.clm
Thelemagick Library - The New Comment to Liber AL vel Legis
Complete List of Orange County Cities + Map (2024) — Orange County Insiders | Tips for locals & visitors
Oppenheimer Showtimes Near B&B Theatres Liberty Cinema 12
Avance Primary Care Morrisville
Ehome America Coupon Code
Hanco*ck County Ms Busted Newspaper
Makes A Successful Catch Maybe Crossword Clue
Deezy Jamaican Food
UWPD investigating sharing of 'sensitive' photos, video of Wisconsin volleyball team
Sacramentocraiglist
Costner-Maloy Funeral Home Obituaries
Prologistix Ein Number
Turning Obsidian into My Perfect Writing App – The Sweet Setup
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 5811

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.