GPG stands for GNU Privacy Guard and it is security software inspired from PGP. It uses public-key cryptography where each user owns two keys: for decryption (public key) and for encryption (private key).
This cheatsheet gives a brief description of that could be done with this security tool.
Keys management
Generate key pair:
gpg --gen-key
Revoke keys:
gpg --gen-revoke
Delete keys:
gpg --delete-key KeyID
gpg --delete-secret-key KeyID
gpg --delete-secret-and-public-key KeyID
View keys:
gpg --list-key
gpg --list-public-keys
gpg --list-secret-keys
Cryptographic options
Encrypt file:
gpg -r KeyID -e -a -o file.out file.in
Decrypt file:
gpg -r KeyID -d -o file.out file.in
Sign a file:
gpg -s KeyID -o file.sig file.in
Detach signature:
gpg -b -a KeyID -o file.sig file.in
Import and Export
Export a private key to a file:
gpg --export-secret-key -a > file.out
Export a public key in a file:
gpg --export --armor KeyID > file.out
Import a private key from a file:
gpg --import --allow-secret-key-import file.in
Import a public key from a file:
gpg --import file.in
Send a public key to a server:
gpg --keyserver keyserver --send-key KeyID
Get a public key from server:
gpg --keyserver keyserver --recv-keys KeyID
[...] kept private and is used to sign and decrypt the data. More info about GPG commands you can gain in GPG Cheatsheet. Create [...]