7.5. Decrypting Files
Problem
You want to decrypt a file that was encrypted with GnuPG.
Solution
Assuming the file is myfile.gpg, decrypt it in place with:
$ gpg myfile.gpg creates myfile
Decrypt to standard output:
$ gpg --decrypt myfile.gpg
Decrypt to a named plaintext file:
$ gpg --decrypt --output new_file_name
myfile.gpg
Discussion
These commands work for both symmetric and public-key encrypted files. You’ll be prompted for a password (symmetric) or passphrase (public-key), which you must enter correctly to decrypt the file.
ASCII encrypted files (with the suffix .asc) are decrypted in the same way as binary encrypted files (with the suffix .gpg).
See Also
gpg(1).
Get Linux Security Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.