gpg command line examples

Creating Your Key

Before you can encrypt or sign files with GPG you must have a key.

~ $ gpg --gen-key

Post the public, ascii side of your key to the web

~ $ gpg --armor --output pubkey.txt --export 'Your Name'
~ $ gpg --send-keys 'Your Name' --keyserver hkp://subkeys.pgp.net

Encrypting / Decrypting

Here we encrypt/decrypt a file that is just for our own use.

~ $ gpg --encrypt --recipient 'Your Name' foo.txt
~ $ gpg --output foo.txt --decrypt foo.txt.gpg

Encrypting for Recipient

gpg --search-keys 'myfriend@his.isp.com' --keyserver hkp://subkeys.pgp.net
gpg --import key.asc
gpg --list-keys
gpg --encrypt --recipient 'myfriend@his.isp.net' foo.txt

Decrypting

gpg --output foo.txt --decrypt foo.txt.gpg

Sitnagures

gpg --verify crucial.tar.gz.asc crucial.tar.gz
gpg --armor --detach-sign your-file.zip

See Also