Skip to content

Instantly share code, notes, and snippets.

@ppartarr
Last active July 23, 2020 08:19
Show Gist options
  • Save ppartarr/13a879d58e6256241b76288c8e92f94a to your computer and use it in GitHub Desktop.
Save ppartarr/13a879d58e6256241b76288c8e92f94a to your computer and use it in GitHub Desktop.
Encrypt email with GPG

How to encrypt an email with the receiver's public key

Prerequisites

  • The receiver's public key. You can usually find this on an OpenPGP keyserver e.g. http://pgp.surfnet.nl/
  • An implementation of the OpenPGP standard such as GnuPG

Import the receiver's public key

gpg --import receiver-key.pub
gpg --keyserver keyserver.example.com --search-key receiver@example.com

# verify the fingerprint
gpg --list-keys --keyid-format LONG --fingerprint

Encrypt the plaintext message

gpg --output message.txt.gpg --encrypt --recipient receiver@example.com message.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment