GPG: Encrypt And Decrypt Files With A Password

From Brian Nelson Ramblings
Revision as of 14:51, 14 March 2014 by Brian (Talk | contribs) (Decrypting a file under Linux using GPG)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
GPG Encrypt&Decrypt

GPG: Encrypt And Decrypt Files With A Password

When looking to encrypt a file, one of the best choices are to use GPG, GPG is a free service that almost all servers come with. You can encrypt and decrypt a file using GPG.

gnup

GnuPG stands for GNU Privacy Guard and GNU's tool for secure communctions and data storage.

Encrypting a file under Linux using GPG

To encrypt a single file, aka a password file run:

gpg -c password.txt

It will ask you to create a password on for the file after running that command.

You will notice that in your directory you see a file called password.txt.gpg

Now it will keep the original file as well as create the password.txt.gpg

Now I would suggest removing the orginal password.txt file

rm password.txt

Decrypting a file under Linux using GPG

Now whats the fun of encrypting the file, if you can not use it.

Well now you will need to decrypt the file to view the contents.

gpg -d password.txt.gpg

Now that will display in your terminal, say you want to modify the file, you will need to save that to a file and re encrypt it

gpg  -o password.txt -d password.txt.gpg

Add/Remove information from password.txt, and re encrypt it

gpg -c password.txt && rm password.txt

Please note that if you ever forgot your password (passphrase), you cannot recover the data as it use very strong encryption.