GnuPG Encryption Cheat Sheet

Forketyfork
CodeX
Published in
4 min readApr 8, 2021

--

Image by 👀 Mabel Amber, who will one day from Pixabay

GnuPG (gpg) is a great utility that is usually available both on Linux and Mac. It can be used for generating encryption and signing keys and using them to encrypt and decrypt your sensitive data. Here’s a quick cheat sheet for basic usage scenarios.

Generating a new key

Generate a new gpg key:

gpg --full-generate-key

The utility will ask some questions, for most of them the default values are fine:

  • What kind of key you want? (RSA and RSA)
  • What keysize do you want? (3072)
  • How long the key should be valid? (the key does not expire)
  • Real name? (Input a name to identify the key)
  • Email address? (Input the email address that you want to be associated with the key)
  • Passphrase to secure the key.

Make sure you memorize the passphrase and store it in a secure place, otherwise you’ll lose access to the key, and, consequently, to the encrypted files. An example of the generation output is provided below.

$ gpg --full-generate-key
gpg (GnuPG) 2.2.19; Copyright (C) 2019 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by…

--

--

Forketyfork
CodeX

Software developer @ JetBrains CodeCanvas. I write technical how-to articles and occasional rants on software development in general. Opinions are my own.