Go to ...


A Better Technical Repository

RSS Feed

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