Gpg
Introduction
GNU Privacy Guard (GnuPG or GPG) is a free, open-source replacement for PGP
See http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/gpg-cs.html for a nice cheatsheet
Install GnuPG (Ubuntu)
sudo apt install gnupg
Create a GPG keypair
gpg --full-generate-key
Share a public-key with the world
Don't worry this is safe.
gpg --send-keys --keyserver pgp.mit.edu KEY_ID
List keys on your "keyring"
gpg --list-keys
Or to show just private keys
gpg --list-secret-keys
View (public) keys in a keyring
(used by apt, apt-get, etc)
gpg --show-keys /etc/apt/keyrings/hashicorp.asc
Exchange/copy a private key
gpg --export-secret-key -a "Mark Foster" > private.keygpg --allow-secret-key-import --import private.key
Show a key's fingerprint
You might do this for a key-signing party or want to validate someone
gpg --fingerprint KEY_ID
Sign a document or file
There are multiple was to do this. I find the detached signature the most useful
gpg -b filename
this creates filename.sig.
To verify the signature (this proves the original filename was not tampered with)
gpg --verify filename.sig
Sign (as above) but "clearsign" which generates ASCII output
(creates filename.asc)
gpg --clearsign /path/to/filename
Encrypt a file (different from signing)
gpg --encrypt /path/to/filename
Decrypt a file (signed or encrypted)
gpg -d /path/to/filename.asc
Things you can do without a key
Encrypt a file
With a password (symmetric key)
gpg -c filename
Decrypt same file
gpg --decrypt filename