🌑

Linhost.info

Encrypt files with GPG on Linux

Linux distributions among them Ubuntu include GPG which is used to encrypt files in a very simple and straight forward manner. The whole process for encrypting a file with GPG requires less manual input when compared to OpenSSL. Do not forget, there is no way to reset the password once a file has been encrypted without access the to original password. Excerpt from Wikipedia GNU Privacy Guard (GnuPG or GPG) is a free open source alternative to the PGP suite of cryptographic software. GnuPG is compliant with RFC 4880, which is the current IETF standards track specification of OpenPGP.

How to use GPG

To encrypt a file all you need to do is type gpg, followed by -c to encrypt with a symmetric cipher and the name of the file you want to encrypt.

gpg -c filename.pdf

Then you will be asked to provide a password for the encrypted file twice.

Enter passphrase: mypassword
Repeat passphrase: mypassword

The result will a file with the file extension ending in .gpg, for example filename.pdf becomes filename.pdf.gpg indicating the file has been encrypted with GPG.

Decrypt the file

To decrypt the file the process is similar. Just type gpg and the file name, you will then be asked to provide the password for the encrypted file.

gpg filename.pdf.gpg

and provide the passphrase needed to decrypt the file.

Enter passphrase: mypassword

The file will now be decrypted and presented in it’s original format.

References

GPG on Wikipedia

— Feb 2, 2009