[PLUG] Command to encrypt files

Smith, Cathy Cathy.Smith at pnnl.gov
Sun Aug 17 18:55:45 UTC 2014


There are lot of good references on-line for using GPG.  Depending on what you want, you don't have to learn everything to just get started.  The commands listed below are usually enough to get started.  If you want some links, send me your email address and I'll include a few that I use.


Cathy

---
Cathy L. Smith
IT Engineer

Pacific Northwest National Laboratory
Operated by Battelle for the
U.S. Department of Energy

Phone:      509.375.2687
Fax:        509.375.2330
Email:      cathy.smith at pnnl.gov


-----Original Message-----
From: plug-bounces at lists.pdxlinux.org [mailto:plug-bounces at lists.pdxlinux.org] On Behalf Of Martin A. Brown
Sent: Sunday, August 17, 2014 11:33 AM
To: Portland Linux/Unix Group
Subject: Re: [PLUG] Command to encrypt files


> My OS: Mint Linux 16

> New member here. I would like to know if there is a command to encrypt 
> files? I thought it was "crypt" but I see that is in section 3 of the 
> man pages, meaning it's a programming function.

I'm a command-line monster, so I would reach first for 'gpg'.  It's part of the 'gnupg' package.  I had a PDF hanging around in my home directory, and am using that as an example file below. These two commands do the same thing, just that one of them allows you to explicitly name the output file.  Regardless of the invocation, you will be prompted to type the encryption passphrase twice.

   gpg --output W472242.PDF.gpg --symmetric -- W472242.PDF
   gpg --symmetric -- W472242.PDF

Then, to recover your data, you would decrypt as follows.

   gpg --output W472242.PDF.aaa --decrypt -- W472242.PDF.gp
   gpg --decrypt -- W472242.PDF.gpg  > W472242.PDF.bbb

And, to verify that the encryption and decryption worked, you can see that I used the 'md5sum' utility to get a checksum of my data before and after.

   $ md5sum  W472242.PDF*
   c787744f66f790efeef893016c4ad587  W472242.PDF
   c787744f66f790efeef893016c4ad587  W472242.PDF.aaa
   c787744f66f790efeef893016c4ad587  W472242.PDF.bbb
   f464112b24fe58c06f5a6f2eab6d7e2a  W472242.PDF.gpg

Note that gpg can also handle public-key cryptography (which involves key-pairs) in addition to the simpler encryption shown above.  It is called symmetric, because you use the same passphrase for encryption as for decryption.

-Martin

--
Martin A. Brown
http://linux-ip.net/
_______________________________________________
PLUG mailing list
PLUG at lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug



More information about the PLUG mailing list