
We fight for computer users' rights, and promote the development of free (asin freedom) software. Resisting bulk surveillance is very important to us.
Please donate to support Email Self-Defense. We need to keepimproving it, and making more materials, for the benefit of people aroundthe world taking the first step towards protecting their privacy.
Bulk surveillance violates our fundamental rights and makes free speechrisky. This guide will teach you a basic surveillance self-defense skill: emailencryption. Once you've finished, you'll be able to send and receive emailsthat are scrambled to make sure a surveillance agent or thief interceptingyour email can't read them. All you need is a computer with an Internetconnection, an email account, and about forty minutes.
Even if you have nothing to hide, using encryption helps protect the privacyof people you communicate with, and makes life difficult for bulk surveillancesystems. If you do have something important to hide, you're in good company;these are the same tools that whistleblowers use to protect their identitieswhile shining light on human rights abuses, corruption, and other crimes.
In addition to using encryption, standing upto surveillance requires fighting politically for areductionin the amount of data collected on us, but the essential first step isto protect yourself and make surveillance of your communication as difficultas possible. This guide helps you do that. It is designed for beginners, butif you already know the basics of GnuPG or are an experienced free softwareuser, you'll enjoy the advanced tips and theguideto teaching your friends.
This guide relies on software which isfreely licensed;it's completely transparent and anyone can copy it or make theirown version. This makes it safer from surveillance than proprietarysoftware (like Windows or macOS). Learn more about free software atfsf.org.
Most GNU/Linux operating systems come with GnuPG installed on them, so if you're running one of these systems, you don't have to download it. If you're running macOS or Windows, steps to download GnuPG are below. Before configuring your encryption setup with this guide, though, you'll need a desktop email program installed on your computer. Many GNU/Linux distributions have one installed already, such as Icedove, which may be under the alternate name "Thunderbird." Programs like these are another way to access the same email accounts you can access in a browser (like Gmail), but provide extra features.

Open your email program and follow the wizard (step-by-step walkthrough)that sets it up with your email account. This usually starts from "Account Settings" → "Add Mail Account". You should get the email server settings from your systems administrator or the help section of your email account.
If you are using a GNU/Linux machine, you should already have GnuPG installed, and you can skip toSection 2.
If you are using a macOS or Windows machine, however, you need to first install the GnuPG program. Select your operating system below and follow the instructions. For the rest of this guide, the steps are the same for all operating systems.
The default macOS package manager makes it difficult to install GnuPG and other pieces of free software (like Emacs, GIMP, or Inkscape). To make things easier, we recommend setting up the third-party package manager "Homebrew" to install GnuPG. For this, we will use a program called "Terminal," which is pre-installed on macOS.
# Copy the first command on the home page ofHomebrew by clicking on the clipboard icon, and paste it in Terminal. Click "Enter" and wait for the installation to finalize.
# Then install GnuPG by entering the following code in Terminal:brew install gnupg gnupg2
GPG4Win is an email and file encryption software package that includes GnuPG. Download and install the latest version, choosing default options whenever asked. After it's installed, you can close any windows that it creates.
In general, the terms GnuPG, GPG, GNU Privacy Guard, OpenPGP and PGPare used interchangeably. Technically, OpenPGP (Pretty Good Privacy) is theencryption standard, and GNU Privacy Guard (often shortened to GPG or GnuPG)is the program that implements the standard. Most email programs provide an interface for GnuPG. There is also a newer version of GnuPG, called GnuPG2.

To use the GnuPG system, you'll need a public key and a private key (knowntogether as a keypair). Each is a long string of randomly generated numbersand letters that are unique to you. Your public and private keys are linkedtogether by a special mathematical function.
Your public key isn't like a physical key, because it's stored in the openin an online directory called a keyserver. People download it and use it,along with GnuPG, to encrypt emails they send to you. You can think of thekeyserver as a phonebook; people who want to send you encrypted email canlook up your public key.
Your private key is more like a physical key, because you keep it toyourself (on your computer). You use GnuPG and your private key together todescramble encrypted emails other people send to you.You should never share your private key with anyone, under anycircumstances.
In addition to encryption and decryption, you can also use these keys tosign messages and check the authenticity of other people's signatures. We'lldiscuss this more in the next section.


We will use the command line in a terminal to create a keypair using theGnuPG program.
Whether on GNU/Linux, macOS or Windows, you can launch yourterminal ("Terminal" in macOS, "PowerShell" in Windows) from the Applicationsmenu (some GNU/Linux systems respond to theCtrl + Alt + Tshortcut).
# Entergpg --full-generate-key to start the process.
# To answer what kind of key you would like to create, select the default option:1 RSA and RSA.
# Enter the following keysize:4096 for a strong key.
# Choose the expiration date; we suggest2y (2 years).
Follow the prompts to continue setting up with your personal details.
Depending on your version of GPG, you may need to use--gen-key instead of--full-generate-key.
You can set further options by runninggpg --edit-key [your@email] in aterminal window.
On the screen titled "Passphrase," pick a strong passphrase! You cando it manually, or you can use the Diceware method. Doing it manuallyis faster but not as secure. Using Diceware takes longer and requiresdice, but creates a passphrase that is much harder for attackers to figureout. To use it, read the section "Make a secure passphrase with Diceware" inthis article by Micah Lee.
If you'd like to pick a passphrase manually, come up with somethingyou can remember which is at least twelve characters long, and includesat least one lower case and upper case letter and at least one number orpunctuation symbol. Never pick a passphrase you've used elsewhere. Don't useany recognizable patterns, such as birthdays, telephone numbers, pets' names,song lyrics, quotes from books, and so on.
gpg --version.If GnuPG is not installed, it will bring up the following result on most GNU/Linux operating systems, or something like it:Command 'gpg' not found, but can be installed with: sudo apt install gnupg. Follow that command and install the program.sudo apt updatesudo apt install gnupg2gpg2 --full-generate-key Depending on your version of GPG, you may need to use--gen-key instead of--full-generate-key.
gpg --list-keys. Yours should be listed in there, and later, so will Edward's (Section 3).gpg --list-key [your@email].gpg --list-secret-key to see your own private key.
We will upload your key to a keyserver, so if someone wants to send you an encrypted message, they can download your public key from the Internet. There are multiple keyserversthat you can select from the menu when you upload, but they are mostly all copiesof each other. Any server will work, but it's good to remember which one you uploaded your key to originally. Also keep in mind, sometimes takes a few hours for them to match each other when a new key is uploaded.
# Copy your keyID:gpg --list-key [your@email] will list your public ("pub") key information, including your keyID, which is a unique list of numbers and letters. Copy this keyID, so you can use it in the following command.
# Upload your key to a server:gpg --send-key [keyID]
Use the following command to export your secret key so you can import it into your email client at the nextstep. To avoid getting your key compromised, store this in a safe place, and make sure that if it is transferred, it is done so in a trusted way. Exporting your keys can be done with the following commands:
$ gpg --export-secret-keys -a [keyID] > my_secret_key.asc
$ gpg --export -a [keyID] > my_public_key.asc
Just in case you lose your key, or it gets compromised, you want to generate a certificate and choose to save it in a safe place on your computer for now (please refer toStep 6.C for how to best store your revocation cerficate safely). This step is essential for your email self-defense, as you'll learn more about inSection 5.
# Copy your keyID:gpg --list-key [your@email] will list your public ("pub") key information, including your keyID, which is a unique list of numbers and letters. Copy this keyID, so you can use it in the following command.
# Generate a revocation certificate:gpg --gen-revoke --output revoke.asc [keyID]
# It will prompt you to give a reason for revocation, we recommend to use1 = key has been compromised.
# You don't have to fill in a reason, but you can; then press "Enter" for an empty line, and confirm your selection.
gpg --keyserver keys.openpgp.org --send-key [keyID].Like every other file or folder, gpg keys are subject to permissions. If these are not set correctly, your system may not be accepting your keys. You can follow the next steps to check, and update to the right permissions.
# Check your permissions:ls -l ~/.gnupg/*
# Set permissions to read, write, execute for only yourself, no others. These are the recommended permissions for your folder.
You can use the command:chmod 700 ~/.gnupg
# Set permissions to read and write for yourself only, no others. These are the recommended permissions for the keys inside your folder.
You can use the code:chmod 600 ~/.gnupg/*
If you have (for any reason) created your own folders inside ~/.gnupg, you must also additionally apply execute permissions to that folder. Folders require execution privileges to be opened. For more information on permissions, you can check outthis detailed information guide.
Use the following commands to transfer your keys. To avoid getting your key compromised, store it in a safe place, and make sure that if it is transferred, it is done so in a trusted way. Importing and exporting a key can be done with the following commands:
$ gpg --export-secret-keys -a [keyID] > my_private_key.asc
$ gpg --export -a [keyID] > my_public_key.asc
$ gpg --import my_private_key.asc
$ gpg --import my_public_key.asc
Ensure that the keyID printed is the correct one, and if so, then go ahead and add ultimate trust for it:
$ gpg --edit-key [your@email]
Because this is your key, you should chooseultimate. You shouldn't trust anyone else's key ultimately.
Refer toTroubleshooting in Step 2.B for more information on permissions. When transferring keys, your permissions may get mixed, and errors may be prompted. These are easily avoided when your folders and files have the right permissions
The Icedove (or Thunderbird) email program has PGP functionality integrated, which makes it pretty easy to work with. We'll take you through the steps of integrating and using your key in these email clients.




Once you have set up your email with encryption, you can start contributing to encrypted traffic on the Internet. First we'll get your email client to import your secret key, and we will also learn how to get other people's public keys from servers so you can send and receive encrypted email.
# Open your email client and use "Tools" →OpenPGP Key Manager
# Under "File" →Import Secret Key(s) From File
# Select the file you saved under the name [my_secret_key.asc] inStep 2.B when you exported your key
# Unlock with your passphrase
# You will receive a "OpenPGP keys successfully imported" window to confirm success
# Go to "Account settings" → "End-To-End Encryption," and make sure your key is imported and selectTreat this key as a Personal Key.

Now you'll try a test correspondence with an FSF computer program named Edward,who knows how to use encryption. Except where noted, these are the samesteps you'd follow when corresponding with a real, live person.

This is a special step that you won't have to do when correspondingwith real people. In your email program's menu, go to "Tools" → "OpenPGP KeyManager." You should see your key in the list that pops up. Right clickon your key and selectSend Public Keys by Email. This will create a new draft message, as if you had just hit the "Write" button, but in the attachment you will find your public keyfile.
Address the message toedward-en@fsf.org. Put at least one word(whatever you want) in the subject and body of the email. Don't send yet.
We want Edward to be able to open the email with your keyfile, so we want this first special message to be unencrypted. Make sure encryption is turned off by using the dropdown menu "Security" and selectDo Not Encrypt. Once encryption is off, hit Send.
It may take two or three minutes for Edward torespond. In the meantime, you might want to skip ahead and check out theUse it Well section of this guide. Once you have received a response,head to the next step. From here on, you'll be doing just the same thing aswhen corresponding with a real person.
When you open Edward's reply, GnuPG may prompt you for your passphrasebefore using your private key to decrypt it.


To encrypt an email to Edward, you need its public key, so now you'll haveto download it from a keyserver. You can do this in two different ways:
Option 1. In the email answer you received from Edward as a response to your first email, Edward's public key was included. On the right of the email, just above the writing area, you will find an "OpenPGP" button that has a lock and a little wheel next to it. Click that, and selectDiscover next to the text: "This message was signed with a key that you don't yet have." A popup with Edward's key details will follow.
Option 2. Open your OpenPGP Key manager, and under "Keyserver" chooseDiscover Keys Online. Here, fill in Edward's email address, and import Edward's key.
The optionAccepted (unverified) will add this key to your key manager, and now it can be used to send encrypted emails and to verify digital signatures from Edward.
In the popup window confirming if you want to import Edward's key, you'll see many different emails that are all associated with its key. This is correct; you can safely import the key.
Since you encrypted this email with Edward's public key,Edward's private key is required to decrypt it. Edward is the only one withits private key, so no one except Edward can decrypt it.
Write a new email in your email program, addressed toedward-en@fsf.org. Make the subject"Encryption test" or something similar and write something in the body.
This time, make sure encryption is turned on by using the dropdown menu "Security" and selectRequire Encryption. Once encryption is on, hit Send.
Even if you encrypt your email, the subject line is not encrypted, sodon't put private information there. The sending and receiving addressesaren't encrypted either, so a surveillance system can still figure out whoyou're communicating with. Also, surveillance agents will know that you'reusing GnuPG, even if they can't figure out what you're saying. When yousend attachments, you can choose to encrypt them or not,independent of the actual email.
For greater security against potential attacks, you can turn offHTML. Instead, you can render the message body as plain text. In orderto do this in Icedove or Thunderbird, go to "View" → "Message Body As" →PlainText.

When Edward receives your email, it will use its private key to decryptit, then reply to you.
It may take two or three minutes for Edward torespond. In the meantime, you might want to skip ahead and check out theUse it Well section of this guide.
Edward will send you an encrypted email back saying your email was received and decrypted. Your email client will automatically decrypt Edward's message.
The OpenPGP button in the email will show a little green checkmark over the lock symbol to show the message is encrypted, and a little orange warning sign which means that you have accepted the key, but not verified it. When you have not yet accepted the key, you will see a little question mark there. Clicking the prompts in this button will lead you to key properties as well.
GnuPG includes a way for you to sign messages and files, verifying thatthey came from you and that they weren't tampered with along the way. Thesesignatures are stronger than their pen-and-paper cousins -- they're impossibleto forge, because they're impossible to create without your private key(another reason to keep your private key safe).
You can sign messages to anyone, so it's a great way to make peopleaware that you use GnuPG and that they can communicate with you securely. Ifthey don't have GnuPG, they will be able to read your message and see yoursignature. If they do have GnuPG, they'll also be able to verify that yoursignature is authentic.
To sign an email to Edward, compose any message to the email address and click thepencil icon next to the lock icon so that it turns gold. If you sign amessage, GnuPG may ask you for your passphrase before it sends the message,because it needs to unlock your private key for signing.
In "Account Settings" → "End-To-End-Encryption" you can opt toadd digital signature by default.
When Edward receives your email, he will use your public key (whichyou sent him inStep 3.A) to verify the messageyou sent has not been tampered with and to encrypt a reply to you.
It may take two or three minutes for Edward torespond. In the meantime, you might want to skip ahead and check out theUse it Well section of this guide.
Edward's reply will arrive encrypted, because he prefers to use encryptionwhenever possible. If everything goes according to plan, it should say"Your signature was verified." If your test signed email was also encrypted,he will mention that first.
When you receive Edward's email and open it, your email client willautomatically detect that it is encrypted with your public key, andthen it will use your private key to decrypt it.

Email encryption is a powerful technology, but it has a weakness:it requires a way to verify that a person's public key is actuallytheirs. Otherwise, there would be no way to stop an attacker from makingan email address with your friend's name, creating keys to go with it, andimpersonating your friend. That's why the free software programmers thatdeveloped email encryption created keysigning and the Web of Trust.
When you sign someone's key, you are publicly saying that you've verifiedthat it belongs to them and not someone else.
Signing keys and signing messages use the same type of mathematicaloperation, but they carry very different implications. It's a good practiceto generally sign your email, but if you casually sign people's keys, youmay accidentally end up vouching for the identity of an imposter.
People who use your public key can see who has signed it. Once you'veused GnuPG for a long time, your key may have hundreds of signatures. Youcan consider a key to be more trustworthy if it has many signatures frompeople that you trust. The Web of Trust is a constellation of GnuPG users,connected to each other by chains of trust expressed through signatures.

In your email program's menu, go to OpenPGP Key Manager and selectKey properties by right clicking on Edward's key.
Under "Your Acceptance," you can selectYes, I've verified in person this key has the correct fingerprint.
You've just effectively said "I trust that Edward's publickey actually belongs to Edward." This doesn't mean much because Edward isn'ta real person, but it's good practice, and for real people it is important. You can read more about signing a person's key in thecheck IDs before signing section.
People's public keys are usually identified by their key fingerprint,which is a string of digits like F357AA1A5B1FA42CFD9FE52A9FF2194CC09A61E8(for Edward's key). You can see the fingerprint for your public key, andother public keys saved on your computer, by going to OpenPGP KeyManagement in your email program's menu, then right clicking on the keyand choosing Key Properties. It's good practice to share your fingerprintwherever you share your email address, so that people can double-check thatthey have the correct public key when they download yours from a keyserver.
You may also see public keys referred to by a shorterkeyID. This keyID is visible directly from the Key Managementwindow. These eight character keyIDs were previously used foridentification, which used to be safe, but is no longer reliable. Youneed to check the full fingerprint as part of verifying you have thecorrect key for the person you are trying to contact. Spoofing, inwhich someone intentionally generates a key with a fingerprint whosefinal eight characters are the same as another, is unfortunatelycommon.
Before signing a person's key, you need to be confident that it actuallybelongs to them, and that they are who they say they are. Ideally, thisconfidence comes from having interactions and conversations with them overtime, and witnessing interactions between them and others. Whenever signinga key, ask to see the full public key fingerprint, and not just the shorterkeyID. If you feel it's important to sign the key of someone you've justmet, also ask them to show you their government identification, and makesure the name on the ID matches the name on the public key.
Everyone uses GnuPG a little differently, but it's important to followsome basic practices to keep your email secure. Not following them, yourisk the privacy of the people you communicate with, as well as your own,and damage the Web of Trust.

The more you can encrypt your messages, the better. If you only encryptemails occasionally, each encrypted message could raise a red flag forsurveillance systems. If all or most of your email is encrypted, peopledoing surveillance won't know where to start. That's not to say that onlyencrypting some of your email isn't helpful -- it's a great start and itmakes bulk surveillance more difficult.
Unless you don't want to reveal your own identity (which requires otherprotective measures), there's no reason not to sign every message, whether ornot you are encrypting. In addition to allowing those with GnuPG to verifythat the message came from you, signing is a non-intrusive way to remindeveryone that you use GnuPG and show support for secure communication. If youoften send signed messages to people that aren't familiar with GnuPG, it'snice to also include a link to this guide in your standard email signature(the text kind, not the cryptographic kind).

GnuPG makes email safer, but it's still important to watch out for invalidkeys, which might have fallen into the wrong hands. Email encrypted withinvalid keys might be readable by surveillance programs.
In your email program, go back to the first encrypted email that Edwardsent you. Because Edward encrypted it with your public key, it will have agreen checkmark on the "OpenPGP" button.
When using GnuPG, make a habit of glancing at that button. The programwill warn you there if you get an email signed with a key that can'tbe trusted.
Remember when you created your keys and saved the revocation certificatethat GnuPG made? It's time to copy that certificate onto the safest storage that you have -- a flash drive, disk, or hard drive stored in a safe place in your home could work, not on a device you carry with you regularly. The safest way we know is actually to print the revocation certificate and store it in a safe place.
If your private key ever gets lost or stolen, you'll need this certificatefile to let people know that you are no longer using that keypair.
If you lose your private key or someone else gets a holdof it (say, by stealing or cracking your computer), it'simportant to revoke it immediately before someone else usesit to read your encrypted email or forge your signature. Thisguide doesn't cover how to revoke a key, but you can follow theseinstructions.After you're done revoking, make a new key and send an email to everyonewith whom you usually use your key to make sure they know, including a copyof your new key.
When you use a web browser to access your email, you're using webmail,an email program stored on a distant website. Unlike webmail, your desktopemail program runs on your own computer. Although webmail can't decryptencrypted email, it will still display it in its encrypted form. If youprimarily use webmail, you'll know to open your email client when you receivea scrambled email.
First add your public key fingerprint to your email signature, thencompose an email to at least five of your friends, telling them you justset up GnuPG and mentioning your public key fingerprint. Link to this guideand ask them to join you. Don't forget that there's also an awesomeinfographic to share.
Start writing your public key fingerprint anywhere someonewould see your email address: your social media profiles, blog, Website,or business card. (At the Free Software Foundation, we put ours on ourstaff page.) We need to get ourculture to the point that we feel like something is missing when we see anemail address without a public key fingerprint.