back to cdrmack

gpg examples

Install gnupg(1) and generate keys.

  pkg install gnupg
  gpg --full-generate-key
  gpg --list-keys

Sign and encrypt single file.

  gpg -r gpg.5kky7@passmail.net -e -s foo.txt
  # gpg --recipient gpg.5kky7@passmail.net --encrypt --sign foo.txt

Decrypt file (will also verify as long as there is a signature).

  gpg -o foo.txt -d foo.txt.gpg
  # gpg --output foo.txt --decrypt foo.txt.gpg

The following won’t work because gpg first signs then encodes the data. Because of that the signature is hidden.

  gpg --verify foo.txt.gpg

I use gpgtar(1) for encoding directories.

It’s also possible to encode (and sign) with symmetric key (password).

  gpg --symmetric -s --cipher-algo AES256 foo.txt
  gpg -o foo.txt -d foo.txt.gpg