We are still actively working on the spam issue.


From InstallGentoo Wiki
Revision as of 18:47, 20 March 2015 by God (talk | contribs) (added new tutorial material)
Jump to: navigation, search

Pretty Good Privacy (PGP) is a data encryption and decryption computer program that provides cryptographic privacy and authentication for data communication. PGP is often used for signing, encrypting, and decrypting texts, e-mails, files, directories, and whole disk partitions and to increase the security of e-mail communications. It was created by Phil Zimmermann in 1991.

PGP, GPG, and similar software follow the OpenPGP standard (4880) for encrypting and decrypting data.


PGP relies on asymmetric encryption, and also can work with symmetric encryption. There are two main modes of operation: signing and encrypting. They may be (should be) combined. If used properly, PGP is one of the strongest and most versatile forms of encryption on the market, however it is extremely complex.


A user uses their private key to create a cryptographic signature, which can be verified by anyone who has their public key. This cryptographically proves that the message came from the holder of the key.


A user can encrypt a file in one of two ways, either with another user's public key, or with a symmetric key. By signing with the public key of a user, it can only be decrypted by their private key, which only they should have. Signing with a symmetric key (a password) is stronger and less CPU-intensive, but has the issue of sending the password to another person.

Where do I get it?

Where do I get it?

GPG stands for Gnu Privacy Guard, an OpenPGP implementation from our favourite freetards at the FSF

Macfags: http://gpgtools.org

Linuxfags: Install gpg from your favorite package manager.

Winfags http://gpg4win.org

Proper and safe Usage

Use [[1]].

Start by reading the documentation, there are many good tutorials out there. The man page is great for greping if you need more info on a specific option.

Proper Usage

Getting started

You need to make a key first. This is simple as

gpg --gen-key

and answering some questions. You'll be asked for a name and email. You don't have to use real info here, but choose something you like because you can't change it later.

A note: If you will be sharing messages on image boards (a great place, mind you), decide how long you want your key to be. A 4096 bit key might be super secure, but it also means you'll run into post limits on most boards. Choose carefully. ElGamal also has shorter signatures, and should be chosen over RSA.

Usually you'll see keys and messages as a bunch of noise - they're base64 encoded (or "ASCII armored").

Exchanging keys

Now, you need to post your public key. If you do a

gpg --export --armor (part of the name you chose earlier)

The --armor is necessary to encode as text rather than binary. If you will be sharing as a file, binary is fine, but to post messages in emails and on imageboards, it must be text

You'll get a blob of text back that starts with "BEGIN PGP PUBLIC KEY BLOCK". Copy that and paste it to its destination, including the begin and end bits.

You need a public key for the person you want to send a message to. Do

gpg --import

and pasting their key in, ending with Control + D.


The alternative is to locate someone's key on a public key server instead of manually exchanging keys. pgp.mit.edu is a good one.

gpg --keyserver pgp.mit.edu --send-keys <keyID>

Find your key ID by running

gpg -k


gpg --list-keys

Then look for the string under "pub" that is xxxx/<KeyID>

To search on a keyserver for someones key:

gpg --keyserver pgp.mit.edu --search-keys {Name | KeyID | Email}

Then it will give you a few options, and it will allow you to type the number of the key you want from the results, and it will import it for you.

Regular Usage

Encrypting/Decrypting shit

Encrypt a message to somone:

gpg --encrypt --armor --recipient {name | KeyID | email}

To decrypt a message, use:

gpg --decrypt

To sign a message, use

gpg --sign

to make a signature, or

gpg --clearsign

for a ASCII signature.

To test a signed message to see if it is valid:

gpg --verify

You can use short flags or long flags, like -e or --encrypt, and you can combine them like such:

gpg -sear {Name | KeyID | Email}

-sear is a go to flag combo, as it means it will sign, encrypt, armor, and define recipient for the following message.

You can make groups. Go into gpg.conf, (~/.gnupg/gpg.conf on Linux) you can define groups anywhere with an uncommented line like such:

group 8ch = Alice Jones KeyIDHere [email protected]

Using this, you can now encrypt to multiple recipients WITHOUT doing -r X -r Y -r Z for persons X, Y, and Z, instead you can run gpg -sear 8ch, assuming you have the line group 8ch = X Y Z

Regarding concerns, -r and -R (or --recipient and --Recipient) do two different things, -R/ --Recipient removes metadata from the recipients, and this is a personal choice you can make when encrypting things. If you want people to know who the message is encrypted to, use -r, if not, -R

GPG and files

GPG normally works by taking STDIN (standard input, aka what you type/paste into the terminal), operating on it, then dumping the results to STDOUT (standard output, aka what comes spitting up on your teminal)

This can be changed to have GPG input from and/or output to files. One way is shell redirection ( < file, > file )

GPG looks for a filename at the end of the options, if it finds one, this is used for input.

The -o <filename> option will send output to the named file rather than STDOUT.


gpg -sear [email protected] -o output_file.gpg input_file

Safe Usage

Do not ever lose your private key. Safest practice is to use a master key and use it to sign sub keys, then use the sub keys. Keep the master key on an air-gapped computer, and mainly use the subkeys for proper Compartmentalization. Have revocation certificates handy in case your keys are lost.

Make sure you have a password on your keys. This is not enough to stop a determined attacker, so when you are transporting them in an easily seized form, like a flash drive, you should pack your keys into a tarball with some padding (the ~/.gnupg directory works nicely) and encrypt it with AES 256 and a strong password.

ElGammal keys should be used in preference to RSA due to security concerns around RSA. Due to backwards compatibility, many defaults are weak, and should be changed.


Web of Trust

PGP public keys work on a Web of Trust model which means that in order for you to trust that the key you have actually belongs to your contact, you must establish an unbroken chain of trust between them and yourself.

For example, if you want to talk to Bob but haven't exchanged keys with him in person, you need a chain of people between you and Bob who have all signed each others keys. Bob knows Jane, Jane knows Fred, Fred knows Arthur, Arthur knows Sally, Sally knows Claire, and you know Claire.

Without this chain of trust, you can't be sure that you have Bob's true key.


Email encrypted with PGP does nothing to stop metadata being collected about who you contacted, when and how often. A journalist using PGP to talk to a source is not hiding their source.

Useful Links

[Zimmerman: Why I wrote PGP]