Encryption Using GPG

Encrypting a file with GPG so that it is password protected is fairly easy.  I will use the file file.txt as an example, but you can obviously use any file you wish.  First, open up a terminal, and cd into the directory with the file you wish to encrypt.  Then run the following:

[brad@localhost ~]$ gpg --symmetric file.txt

You will be prompted for your pass-phrase twice. Type in the same password both times and now you should see a file named file.txt.gpg (If your original filename is not file.txt then it will be whatever the original filename is + .gpg).  Remove the original file, but leave the .gpg one.  If you really want to make sure the original is gone use shred -z –remove [original_file_name].  Shred rewrites the space on the hard-drive where the file is located so that it is almost impossible to recover any information.  Note that without the –remove option shred does not remove the file, but all of the file’s contents will still be corrupted.

Decryption

To decrypt the file run the following command:

[brad@localhost ~]$ gpg --output file.txt --decrypt file.txt.gpg

You will be prompted for your password so type it in and hit enter.  The decrypted file will be named whatever you enter in after –output.

Summary

To encrypt a file do the following:

  1. Open a terminal.
  2. CD into the folder with the file you wish to encrypt.
  3. Run the command gpg –symmetric [file_name].
  4. Enter in your password twice.  A new file named [file_name].gpg should have been created.  This is the encrypted and password protected file.
  5. Run the command shred -z –remove [file_name].  DO NOT shred the encrypted file as well.

To decrypt a file perform the following:

  1. Open a terminal.
  2. CD to the location where your encrypted file is located.
  3. Run the command gpg –output [file_name] –decrypt [file_name].gpg.
  4. Enter your password.
  5. The original file should be recreated.  This file is neither password protected nor encrypted.

0 Responses to “Encryption Using GPG”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.