July 10

Security: A GPG Cheat Sheet

GPG is an outstanding security program that allows you to encrypt files based on someone’s public key. ¬†The file is then decrypted by the private key of the public key holder once they receive it.

This is my version of a gpg survival guide.

Pulling someone’s key
gpg –keyserver pool.sks-keyservers.net –recv-keys bbc81a91

Sending your key to a public keyserver
gpg –send-keys bbc81a91

Refreshing your keys from a keyserver
gpg –refresh-keys

Generating a key
gpg –gen-key

Exporting a public key
gpg –export -a “Key Name” > pub.key

Exporting a private key
gpg –export-secret-key -a “Key Name” > priv.key

Deleting a private key
gpg –delete-secret-key “Key Name”

Deleting a public key
gpg –delete-key “Key Name”

Importing a key
gpg –import public.key

Listing the keystore
gpg –list-keys

View the entire fingerprint key of all of your installed keys
gpg –list-keys –fingerprint

Search a keyserver
gpg –search-keys –keyserver pool.sks-keyservers.net “name”

Encrypting a file for someone using there public key so only they can decrypt it
gpg –encrypt –recipient “Their Name” filename.txt

Encrypting a file for someone using there public key and your public key so you both can decrypt it.
gpg –encrypt –recipient “Their Name” –recipient “Your Name” filename.txt

You can also define groups of people to encrypt messages to by defining the group in the gpg.config file
gpg –encrypt –recipient myfriends¬†filename.txt

Decrypt a file to the screen
gpg –decrypt filename.txt.gpg

Decrypt a file to disk
gpg filename.txt.gpg

Shorthand version of gpg”
gpg -e -r “There Name” filename.txt

This post was inspired by Citizenfour and Laura Poitras


Copyright 2021. All rights reserved.

Posted July 10, 2016 by Timothy Conrad in category "Security

About the Author

If I were to describe myself with one word it would be, creative. I am interested in almost everything which keeps me rather busy. Here you will find some of my technical musings. Securely email me using - PGP: 4CB8 91EB 0C0A A530 3BE9 6D76 B076 96F1 6135 0A1B