If you're just starting out with MIT freeware PGP on the command line, you can get by with a very few simple commands. Your basic chores are
Note that these commands are given in the command shell. That means you have to export the file from your email program, do the PGP stuff to the file, then re-insert the PGP-ized file back into your emailer. Note that many email programs now contain shortcuts to these commands from within the email program itself. Otherwise you can use your clipboard or equivalent utility.
The table below gives you the quick and dirty commands. Read on for more explanation of how and why these operations work as they do.
| Command | Explanation |
|---|---|
| pgp -seat inputfile their_user_id -o outputfile -u your_userid | This command takes the inputfile (your outgoing email) and signs it with your secret key, encrypts it with the recipients public key, and converts the message to an ascii text file so it will not be mangled during transport by network email servers. Use this command for encrypting and signing all outgoing mail. |
| pgp -sat inputfile -u your_user_id | This command signs your email with your secret key. Since you are not encrypting this file, anyone will be able to read it, but anyone will be able to verify that you sent it. This command is used for announcements that people must know came from you. If your are a teacher and were announcing an upcoming mid-term exam, you'd want your students to know the message was authentic. You'd use this command. |
| pgp incoming_message_file | This command simply says, "run pgp on the encrypted incoming message." If the file is signed, it authenticates the sender if his public key is on your public keyring, so you know who it came from. PGP then asks you for your passphrase and decrypts the message for you. |
| pgp signed_incoming_message | Since the incoming file has a digital signature attached, PGP automatically looks for a corresponding public key on your public keyring. If PGP finds one, it checks for authenticity and notifies you of the result. Otherwise it tells you authentication is not possible. |
Of course, none of this talks about how you can use PGP to encrypt/decrypt your own personal files on your PC.
Sounds pretty High Falutin', but all this means is that you use two keys in this system of encrypting and decrypting email. When you first run PGP, you create these two digital keys on your computer. You use one key that is distributed freely, and one key that you keep on your system for no one's eyes but your own.
This is an extremely effective system from a privacy perspective. This two-key approach to cryptography has been through a lot of world wide scrutiny and has been shown to be secure. While no system is completely secure, this system would cost a snooper far more in computing resources and number crunching time than could be practical for them. It would cost millions of dollars and years of leased super computing time to crack an encrypted PGP secret key. It will certainly protect your personal and financial secrets from prying eyes.
When you encrypt a message to someone, you use their public key to do so. A public key may only be used to "lock" (encrypt) a file; it will not unlock an encrypted file. And a person's secret key is the only key that can "unlock" (decrypt) that file. You can't use your secret key to encrypt a file for someone else to read. Therefore, the public key should be shared widely while the secret key must be protected. Your two PGP keys operate as a team together.
PGP can handle encrypting files to yourself, but with email, you normally are involving one or more other people. (We don't usually send ourselves email, do we?)
Everyone using PGP has two digital keys: a public key and a private key. If Moe wants to send Larry and Curly an encrypted message, he needs a copy of their public keys on his public keyring. (You have two keyrings, by the way: your public keyring and your private keyring.)
Moe first creates his message with a text editor or his built-in text editor in his email program. He types the following into a text file called 2duhstooges.txt:
You knuckleheads! Spread out!
He encrypts this message so only Larry and Curly can read it. He also wants to sign the message with his secret key (so Larry and Curly know that the message had to come from Moe since only Moe knows the passphrase to be able to use his secret key). At the command line Moe types:
pgp -seat 2duhstooges.txt larry@stooge.com curly@stooge.com -o 2duhstooges.asc -u moe@stooge.com <RETURN>
When Moe looks at his text file named 2duhstooges.asc he will see the following:
-----BEGIN PGP MESSAGE----- Version: 2.6.2 hIsDxBGuF+I1zOkBA/Y5/mbuMn+f1drbhTHYiaVrwdygQZBD3EdjOq6Aqip5f4jg /Y7mQ6eoRNz90uzwa+9Svb1TpB+/Hc3jCIMvzw1nvsZJBClxp4i/GlXMNxlSNXA+ bFTGktIKqhopFmXayhor4yzU6TmgkJM9tQ4iAqNdIyjPhXXnslHHcG3UaayyhGwD IJdjGI/+lkUBAv9gBAHatQwg8CkbPzFW73SeGmrXNohG5DbXGTlNO/m8dAwcPByh YuRynFK/ICcixMmVv/hwQbrwnRv9AcB8PsjTzWJeS+1oB5mOfbdqu3qa8dfsZ5c3 iD/3oUTWijSqjvamAAAA3yamyFvciO8/yz1a3AH+JzwfOA5cjq7AZtiIG+R5E+aS FZloJdLY3x5xIpP+grq/P+DUZDaH40xUc8b+zq63OtpxrzKorwNwZJ+/8YvKUkYN 4VLOE38kjibehhgqkAFEf1XT+DXVqdAcfK6cH4LfoQx94kyDU6kyRn4/72j9VoMe jqfWh0lnxPz5ZQV/vRWIy2M5yUKxtDXg8NGCW6QbPgioyH6aMZCIlUGhUjDzeZS3 MVFkrM3h2WdeQjQs0vszwo44/7/re1a/bfhpuN4mpd0Zhgvfc4aWkK6ABToYzNw= =Ikx3 -----END PGP MESSAGE-----
Moe puts this text into his email message and mails it to Larry and Curly as per his normal mail procedure. This is what Moe's email will look like going out and what Larry and Curly will get in their email boxes with their Internet Service Providers.
There are times when you want to send an email but you don't want to encrypt it. For example, you may want to announce an updated piece of software that you've authored to a newsgroup. You want all participants to be able to authenticate that you're the author of the message and that no one is impersonating you. Further, there are probably too many people on the newsgroup for you to encrypt the message with all their public keys. (You could use a "newsgroup" key if you needed to, but this introduces a level of security hazard to the process.)
Let's say that Moe is posting an announcement to the alt.fan.stooges newsgroup, and he wants to ensure that everyone can authenticate him as the sender of the message. He must sign the announcement (announcement.txt) with his secret key with the following command:
pgp -sat announcement.txt -o announcement.asc -u moe@stooge.com
Moe then posts this message with his email or newsreader program as per his normal procedure. When someone reads the post on the newsgroup with their newsreader, they will see a digital signature as follows:
-----BEGIN PGP SIGNED MESSAGE----- Oh, a wiseguy, huh? I'll murderize ya... -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBM4kQEDKI/x64hwilAQFghQQAqCZ19rhNbL9dazxYXyMQfi2u98leUPL7 LTc388zmi5JUrCtw4JX/ryZD5VpfqDcdYc09M4gzMRy+iQEaAX6/EQjbRTqfib4m CLZyLtJkDMQsH0nfjFJ+IkY8J7d/OUiYx+UrI3ndCS7TmQuKW15O2+om0LrkTzZi 1Q9FAQEdWPI= =ta7O -----END PGP SIGNATURE-----
Now all alt.fan.stooges readers know that Moe is the author of this post, so long as they have Moe's PGP public key on their public keyrings. PGP will authenticate that Moe's signature is valid.
Larry and Curly have just received the following encrypted email from Moe:
-----BEGIN PGP MESSAGE----- Version: 2.6.2 hIsDxBGuF+I1zOkBA/Y5/mbuMn+f1drbhTHYiaVrwdygQZBD3EdjOq6Aqip5f4jg /Y7mQ6eoRNz90uzwa+9Svb1TpB+/Hc3jCIMvzw1nvsZJBClxp4i/GlXMNxlSNXA+ bFTGktIKqhopFmXayhor4yzU6TmgkJM9tQ4iAqNdIyjPhXXnslHHcG3UaayyhGwD IJdjGI/+lkUBAv9gBAHatQwg8CkbPzFW73SeGmrXNohG5DbXGTlNO/m8dAwcPByh YuRynFK/ICcixMmVv/hwQbrwnRv9AcB8PsjTzWJeS+1oB5mOfbdqu3qa8dfsZ5c3 iD/3oUTWijSqjvamAAAA3yamyFvciO8/yz1a3AH+JzwfOA5cjq7AZtiIG+R5E+aS FZloJdLY3x5xIpP+grq/P+DUZDaH40xUc8b+zq63OtpxrzKorwNwZJ+/8YvKUkYN 4VLOE38kjibehhgqkAFEf1XT+DXVqdAcfK6cH4LfoQx94kyDU6kyRn4/72j9VoMe jqfWh0lnxPz5ZQV/vRWIy2M5yUKxtDXg8NGCW6QbPgioyH6aMZCIlUGhUjDzeZS3 MVFkrM3h2WdeQjQs0vszwo44/7/re1a/bfhpuN4mpd0Zhgvfc4aWkK6ABToYzNw= =Ikx3 -----END PGP MESSAGE-----
Since at this point Larry and Curly don't know this message came from Moe or that the message was even encrypted with their own public keys, all they can do is save the mail to a file (unknown.asc) and issue the command:
pgp unknown.asc
Many email programs can duplicate this command from inside the program itself. But let's assume Larry and Curly don't have such a tool and have to do it the old-fashioned way at the command line. The command above will recreate the plaintext file unkown that will contain the contents of 2duhstooges.txt that Moe sent originally:
You knuckleheads! Spread out!
Now Larry and Curly can do what Moe says before they get in any more trouble!
When Larry and Curly get the message "A wiseguy, huh? . . . " from Moe, they're doubtful that the message is authentic. They don't want to believe that Moe's going to "murderize" them. So, they save the signed file to a text file (murderize.txt) and they execute the PGP signature authentication command on it:
pgp murderize.txt
PGP will come back and give them the result of the signature authentication test:
File has signature. Public key is required to check signature. . Good signature from user "Moe (moe@stooge.com)". Signature made 1997/05/26 04:23 GMT Plaintext filename: murderize.txt
This proves PGP was able to find Moe's public key on the other stooges' public keyrings and that Moe in fact wrote the email.
Copyright, 1997 by David S. Jackson.