GnuPG tips

References

  1. GnuPG Home
  2. Linux Journal article
  3. Handbook (GPH)

ASCII encoding
gpg --enarmor < filename.bin > filename.txt
gpg --dearmor < filename.txt > filename.bin

Alternatives to md5sum
gpg --print-md sha1 filename
gpg --print-md sha1 *.txt
gpg --print-md md5 filename
gpg --print-md sha512 filename

Generate a secure password
gpg --gen-random 1 16 | gpg --enarmor | sed -n 5p

Encrypt a tarball
tar -cf - these files here | gpg -c > these-files-here.tgp

Decrypt a tarball
gpg < these-files-here.tgp | tar -xvf -

Symetric encrypting using a file containing the password
gpg --passphrase-fd 3 -c 3< passphrase.txt < filename.txt > filename.gpg

Symetric decrypting using a file containing a password
gpg --passphrase-fd 3 3< passphrase.txt < filename.gpg > filename.txt

NOTE: To suppress the warning about missing MDC integrity protection, use
--no-mdc-warning

NOTE: To supress all messages and just output the decrypted content
gpg --batch --passphrase-fd 3 3< passfile.txt <filename.gpg 2>/dev/null

NOTE: The following command, as sometimes given, has a problem.
cat passphrase.txt | gpg --passphrase-fd 0 -c < filename.txt > filename.gpg
The stdin (file descriptor 0) of the gpg process is filename txt,
rather than passphrase.txt, so the (intended) passphrase is never actually used!

Mail the encrypted file
gpg --passphrase-fd 3 -ac -o - 3< passphrase.txt < filename.txt | mail user@example.com


Send mail to the Webmaster

logo This site best viewed with a browser
Warning: This is a Debian centric site and MAY contain peanuts.
Many thanks to Debra Lynn and Ian Murdock for making Debian possible
First created Nov 19, 2010 ~ Last revised November 25, 2010

Valid XHTML 1.0 Strict Valid CSS!