<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Secure Email with GnuPG</title>
    <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Secure Email with GnuPG</title>
      <description>&lt;p&gt;So you need to send someone the root password to your webserver? You should just put it in an email and send it to them, right? Well, actually, no&amp;#8230;that&amp;#8217;s a &lt;a href="http://en.wikipedia.org/wiki/E-mail_privacy"&gt;profoundly bad idea&lt;/a&gt;. Here&amp;#8217;s how you can use &lt;span class="caps"&gt;GPG&lt;/span&gt; to securely send passwords (and other sensitive information) though email.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Public-key_cryptography&amp;#38;oldid=152021348"&gt;Public key encryption&lt;/a&gt; allows people to send secure messages to each other without exchanging pre-determined passwords.
&lt;a href="http://www.gnupg.org/"&gt;GnuPG&lt;/a&gt; is an open source implementation of a public key encryption system called OpenPGP. Other public key systems exist, but GnuPGP is both free and Free, so that&amp;#8217;s what we&amp;#8217;ll be using for this example.&lt;/p&gt;


	&lt;p&gt;First, you get to install GnuPG. If your operating system has a package manager such as apt or MacPorts, it&amp;#8217;s generally as simple as:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
sudo port install gpg
&lt;/pre&gt;&lt;/code&gt;&lt;p/&gt;

	&lt;h2&gt;Creating a Key Pair&lt;p/&gt;&lt;/h2&gt;


	&lt;p&gt;Now that we have it installed, lets generate a &lt;i&gt;key pair&lt;/i&gt;. Key pairs allow others to encrypt messages to us using our public key, which we can then decrypt using our private key. Doing this in gpg is simple, just type:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
gpg --gen-key
&lt;/pre&gt;&lt;/code&gt;&lt;p/&gt;

	&lt;p&gt;GnuPG will then ask a set of questions, including a passphrase, name, and email address. The default values it uses for the key settings are generally acceptable. GnuPG will then generate a key and add it to our &lt;i&gt;keyring&lt;/i&gt;, which holds all our known public and private keys. To see the contents of the keyring, we type:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
&amp;gt;gpg --list-keys
pub   1024D/A4D1213F 2007-08-23
uid                  Ben Rady &amp;lt;brady@objectmentor.com&amp;gt;
sub   ...
&lt;/pre&gt;&lt;/code&gt;&lt;p/&gt;

	&lt;p&gt;GnuPG then spits out the public and private key ID&amp;#8217;s. Now that we have a key pair, we can decrypt messages sent to us. But how will anyone get our public key to encrypt messages? Well, we could export our public key and post it on our website. Or we could just email it to everyone we know. However, there are also numerous key servers around the Internet that host public keys, such as the &lt;a href="http://pgp.mit.edu/"&gt;&lt;span class="caps"&gt;MIT&lt;/span&gt; key server&lt;/a&gt;, and we can post our key to one of them. To do so, we type:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
gpg --keyserver pgp.mit.edu --send-keys A4D1213F 
&lt;/pre&gt;&lt;/code&gt;&lt;p/&gt;

	&lt;h2&gt;Sending Encrypted Messages&lt;p/&gt;&lt;/h2&gt;


	&lt;p&gt;So once the receipent has generated a key pair and made their public key available, we can send them a secure message. First, we need to import their public key into our keyring:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
gpg --keyserver pgp.mit.edu --recv-keys A4D1213F
&lt;/pre&gt;&lt;/code&gt;&lt;p/&gt;

	&lt;p&gt;If you don&amp;#8217;t know the key ID that you want to import, the &lt;span class="caps"&gt;MIT&lt;/span&gt; keyserver has a search function that will search by name or email address. However, it&amp;#8217;s important to verify that the key you find in the search is really the public key of your intended recipient. Once we do that we (generally) should mark the key as &lt;i&gt;trusted&lt;/i&gt; by typing:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
gpg --edit-key brady@objectmentor.com
Command&amp;gt; trust
Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)

  1 = I don't know or won't say
  2 = I do NOT trust
  3 = I trust marginally
  4 = I trust fully
  5 = I trust ultimately
  m = back to the main menu

Your decision? 5
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Now, we can create a message and encrypt it:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
echo 'Secure Message' | gpg -e -r brady@objectmentor.com &amp;gt; secure.gpg
&lt;/pre&gt;&lt;/code&gt;&lt;p/&gt;

	&lt;p&gt;We could have just as easily encrypted one or more files by passing them as parameters to GnuPG. We also could have included multiple recipients. Now we can safely email our secure message (stored in the secure.gpg file) to the recipient.&lt;/p&gt;


	&lt;h2&gt;Receiving Encrypted Messages&lt;p/&gt;&lt;/h2&gt;


	&lt;p&gt;When someone sends us an encrypted message, decrypting it is easy.&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
&amp;gt; gpg -d secure.gpg
gpg: encrypted with ...
      "Ben Rady &amp;lt;brady@objectmentor.com&amp;gt;" 
Secure Message
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;And there&amp;#8217;s our secure message. Kept safe from the prying eyes of the Internet.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Aug 2007 09:52:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:eb79bd51-b9b2-4780-9950-46ef5b896de0</guid>
      <author>Ben Rady</author>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg</link>
      <category>Ben's Banal Babble</category>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by Fred</title>
      <description>&lt;p&gt;Thank you guys, very much!&lt;/p&gt;</description>
      <pubDate>Sat, 10 May 2008 15:35:01 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a1bf0f51-8154-4361-86ce-16e6ee9d076b</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-1768</link>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by feedogator</title>
      <description>&lt;p&gt;thanks ben for the great article&lt;/p&gt;</description>
      <pubDate>Wed, 23 Apr 2008 07:20:27 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f32373b2-8ff4-48e5-9b4e-8453621a1edf</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-1722</link>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by wow guild hosting</title>
      <description>&lt;p&gt;Secure email, geting a pair key and sending/receiving encrypted messages is all very valuable. Thank you.&lt;/p&gt;</description>
      <pubDate>Mon, 21 Apr 2008 19:17:25 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0c1ef9e0-42cb-4d2d-a675-2df3ec7478e4</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-1720</link>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by iphone hacks</title>
      <description>&lt;p&gt;Worked on my iphone&lt;/p&gt;</description>
      <pubDate>Thu, 10 Apr 2008 04:57:19 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6f9bdf8d-52ec-4f7a-9534-80cfe3adcb50</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-1708</link>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by Matt Stronge</title>
      <description>&lt;p&gt;Works like a charm, thanks for the great tip!&lt;/p&gt;</description>
      <pubDate>Thu, 10 Apr 2008 04:36:07 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:1fee5bef-3019-499e-a95e-faa5a58d136e</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-1707</link>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by Dave Jerusalem</title>
      <description>&lt;p&gt;Even worked on my Ubuntu machine. Usually these type of tutorials don&amp;#8217;t really work on ubuntu, and with my very limited knowledge in linux I usually just give up, but this actually worked by doing it step by step.&lt;/p&gt;


	&lt;p&gt;thanks mate.&lt;/p&gt;</description>
      <pubDate>Mon, 07 Apr 2008 02:03:42 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:872a7775-5623-4e66-be89-fbd5cfeb9397</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-1691</link>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by rssnewsdigest</title>
      <description>&lt;p&gt;Try rssnewsdigest.com, a new comprehensive news aggregator. With rssnewsdigest, you don &#8217;t really have to go anywhere else.
    &lt;a href="http://rssnewsdigest.com" rel="nofollow"&gt;http://rssnewsdigest.com&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 03 Apr 2008 06:01:29 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a3b237d6-c4c9-4255-bd99-4a5a3c1dc86b</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-1681</link>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by Real estate software</title>
      <description>&lt;p&gt;thank u thank u thank u! I just did that on my iphones freebsd and it worked like magic&lt;/p&gt;</description>
      <pubDate>Sun, 10 Feb 2008 04:43:32 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:8d187f20-e3ec-4c08-9abc-e59a9dce2b16</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-1573</link>
    </item>
    <item>
      <title>"Secure Email with GnuPG" by dan ros</title>
      <description>&lt;p&gt;good site&lt;/p&gt;</description>
      <pubDate>Fri, 09 Nov 2007 02:48:45 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:cad6ba6b-6be3-4bd6-8d2c-d6fbc7440861</guid>
      <link>http://blog.objectmentor.com/articles/2007/08/23/secure-email-with-gnupg#comment-953</link>
    </item>
  </channel>
</rss>
