<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>From Bits to Bites &#38; Windshields to Worship &#187; encryption</title>
	<atom:link href="http://www.mattmckimmy.com/blog/tag/encryption/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattmckimmy.com/blog</link>
	<description>Computers, Cooking, Cars, Christianity, and More ...</description>
	<lastBuildDate>Tue, 18 Oct 2011 02:52:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Setting up LUKS encryption on USB drives</title>
		<link>http://www.mattmckimmy.com/blog/2009/09/21/setting-up-luks-encryption-on-usb-drives/</link>
		<comments>http://www.mattmckimmy.com/blog/2009/09/21/setting-up-luks-encryption-on-usb-drives/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 16:38:41 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[eSATA]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[LUKS]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.mattmckimmy.com/blog/?p=129</guid>
		<description><![CDATA[Part of the "Upgraded Linux Backup" series.

After obtaining (and assembling) my new backup hardware my first order of business was to get the external hard drives formatted and set up with drive encryption. In Ubuntu, the easiest way to encrypt a whole drive is using LUKS - it is easily readable by most Linux computers and can even be set up on a Windows PC, if absolutely necessary. This post will walk through the (remarkably simple) process of setting up encryption and formatting for most any USB flash or hard drive]]></description>
			<content:encoded><![CDATA[<p><em>This post is part of my <a href="http://www.mattmckimmy.com/blog/2009/08/04/upgraded-linux-backu/">Upgraded Linux Backup</a> series.</em></p>
<p>After obtaining (and assembling) my new backup hardware my first order of business was to get the external hard drives formatted and set up with drive encryption. Since I&#8217;m swapping out one drive to store off-site I wanted to use drive encryption just in case it somehow ended up in someone else&#8217;s posession. In Ubuntu, the easiest way to encrypt a whole drive is using LUKS. I chose LUKS because it is easily readable by most Linux computers and can even be set up on a Windows PC, if absolutely necessary. This post will walk through the (remarkably simple) process of setting up encryption and formatting.</p>
<p><span id="more-129"></span>(Note: most of these instructions are condensed adaptations of articles I found <a href="https://help.ubuntu.com/community/EncryptedFilesystemsOnRemovableStorage">here</a> and <a href="https://help.ubuntu.com/community/EncryptedFilesystemHowto">here</a>. )</p>
<p>FYI: I set up my drives using these instructions on Ubuntu 8.10 &#8211; Intrepid Ibex. I was later able to successfully mount and access the drives using Ubuntu 8.04 &#8211; Hardy Heron on my server and 9.04 &#8211; Jaunty Jackalope on my laptop.</p>
<p>When setting up my drives I was using USB 2.0, therefore these directions reflect that. The process may have been faster using eSATA, but at the time I did not yet have a controller card. The directions <em>should</em> be applicable to eSATA as well (unless otherwise noted), but your mileage may vary. These instructions can also be easily adapted for creating a handy, encrypted USB &#8220;thumb&#8221; drive.</p>
<h3 id="Install cryptsetup">Necessary Software</h3>
<p>In order to proceed you must have the <em>cryptsetup</em> package installed:</p>
<pre>sudo apt-get install cryptsetup</pre>
<h3>Finding the drive</h3>
<p>After powering on the drive and hooking it up to the computer you need to identify the device:</p>
<pre>dmesg | tail -20

[33884.688746] usb 4-1: new high speed USB device using ehci_hcd ...
[33884.764079] usb 4-1: configuration #1 chosen from 1 choice
[33884.764868] scsi8 : SCSI emulation for USB Mass Storage devices
[33884.765316] usb-storage: device found at 9
[33884.765321] usb-storage: waiting for device to settle before scan...
[33888.042416] usb-storage: device scan complete
[33888.043707] scsi 8:0:0:0: Direct-Access     HDS72505 0KLA360 ...
[33888.047550] sd 8:0:0:0: [sdb] 976773168 512-byte hardware sectors
[33888.048292] sd 8:0:0:0: [sdb] Write Protect is off
[33888.048300] sd 8:0:0:0: [sdb] Mode Sense: 00 38 00 00
[33888.048305] sd 8:0:0:0: [sdb] Assuming drive cache: write through
[33888.049648] sd 8:0:0:0: [sdb] 976773168 512-byte hardware sectors
[33888.050421] sd 8:0:0:0: [sdb] Write Protect is off
[33888.050428] sd 8:0:0:0: [sdb] Mode Sense: 00 38 00 00
[33888.050432] sd 8:0:0:0: [sdb] Assuming drive cache: write through
[33888.050438]  sdb: unknown partition table
[33888.066470] sd 8:0:0:0: [sdb] Attached SCSI disk
[33888.066545] sd 8:0:0:0: Attached scsi generic sg2 type 0</pre>
<p>In the example above (from <a href="https://help.ubuntu.com/community/EncryptedFilesystemsOnRemovableStorage">this article</a>)  you can see that the drive has been recognized as <strong>/dev/sdb</strong>. Your drives may show up differently (mine appeared as /dev/sdd and /dev/sde.) I&#8217;ll continue to use /dev/sdb to refer to the drive we are working with, but you should replace it with whatever your result is.</p>
<h3>Create the partition</h3>
<p>Before you can actually set up encryption or format the drive, you must create a partition. This is simply a portion of the drive you intend to store data on. A single physical drive may contain multiple partitions (as is usually the case with a linux boot drive) or just one. At this point you could easily choose to set up both an encrypted and a non-encrypted partition on your drive. I didn&#8217;t have a need for this, so I&#8217;ll be continuing with a single partition.</p>
<p>While it can be accomplished via the command line, I chose to use the graphical GParted program, available under the &#8220;System -&gt; Administration -&gt; Partition Editor&#8221; menu.</p>
<p>Choose your device via the drop-down menu in the upper right-hand corner. Then, select the unallocated space and create a new partition that encompasses the entire available space. We do not want to format the partition, only create it, so select &#8220;unformatted&#8221; as the filesystem.</p>
<p><a href="http://www.mattmckimmy.com/blog/wp-content/uploads/2009/09/new_partition.jpg"><img class="aligncenter size-full wp-image-141" title="New Partition" src="http://www.mattmckimmy.com/blog/wp-content/uploads/2009/09/new_partition.jpg" alt="New Partition" width="450" height="227" /></a></p>
<p>Click &#8220;Apply&#8221; and your new partition will be created. You should now have a partition named something like /dev/sdb1 (notice there&#8217;s now a number added.) Once you have created the partition successfully, close GParted.</p>
<h3>Setting up encryption</h3>
<p>The next section is copied verbatim from the aforementioned article:</p>
<p class="line862">The <em>dm-crypt</em>, <em>sha256</em> and <em>aes</em> kernel modules will need to be loaded prior to encrypting the partition:</p>
<pre>sudo modprobe dm-crypt
sudo modprobe sha256
sudo modprobe aes</pre>
<p class="line862">If the following error messages appear when loading <em>sha256</em> and <em>aes</em>:</p>
<pre>sudo modprobe sha256
WARNING: Error inserting padlock_sha ... No such device

sudo modprobe aes
WARNING: Error inserting padlock_aes ... No such device</pre>
<p class="line862">it is an indication that the system does not have a hardware cryptographic device (source: <a class="https" href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/206129">Ubuntu Bug #206129</a>)</p>
<p class="line862">The workaround is to add the following lines (using your favorite editor) to the bottom of <em>/etc/modprobe.d/aliases</em> and re-run the <em>modprobe</em> commands for the <em>sha256</em> and <em>aes</em> kernel modules:</p>
<pre>alias sha256 sha256_generic
alias aes aes_generic</pre>
<p>Note that this is only necessary when we are setting up the drive. Later we will access them through Gnome and won&#8217;t need these modules.</p>
<h3>Encrypting the partition</h3>
<p>Finally, we can run the command to encrypt the /dev/sdb1 partition.</p>
<p>While there are other ways of securing your encrypted drive (such as key file stored locally or on a USB flash drive) I have chosen to use a strong passphrase. Mine is 23 characters long, but any password 12 characters or longer not consisting of dictionary-findable words should suffice.</p>
<p>The tutorial I used recommended the following command:</p>
<pre>sudo cryptsetup --verify-passphrase luksFormat /dev/sdb1 -c aes -s 256 -h sha256</pre>
<p>The LUKS-formatting command above has the following options:</p>
<ul>
<li><em>&#8211;verify-passphrase</em> &#8211; ensures the passphrase is entered twice to avoid an incorrect passphrase being used</li>
<li><em>-c aes &#8211; </em>specifies the use of <a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard">AES</a> encryption (c for cipher)</li>
<li><em>-s 256</em> &#8211; specifies a 256-bit key size</li>
<li><em>-h sha256</em> &#8211; use 256-bit <a href="http://en.wikipedia.org/wiki/SHA">SHA</a> for password hashing</li>
</ul>
<p>However, after reading <a href="https://help.ubuntu.com/community/EncryptedFilesystemHowto">this article</a> I decided to go with 128-bit AES encryption instead, along with a strong passphrase, in hopes of reducing some computational overhead. Therefore, my command instead looked something like:</p>
<pre>sudo cryptsetup --verify-passphrase luksFormat /dev/sdb1 -c aes -s 128 -h sha256</pre>
<h3>Creating the filesystem</h3>
<p>After setting up the encrypted partition, you must open and map it in order to set up the filesystem and begin using it.</p>
<p>Start with:</p>
<pre>sudo cryptsetup luksOpen /dev/sdb1 secureUSB</pre>
<p>Which should prompt you for your passphrase and map the drive to <strong>/dev/mapper/secureUSB</strong>. Now you can format the encrypted partition with a filesystem using whatever method you prefer. I had good luck using GParted to format in ext3.</p>
<p>Like before, select the device you want to create the filesystem on &#8211; in this case /dev/mapper/secureUSB. You should again see a block of unallocated space, which you should select and create a new partition within. You may be presented with a big, scary message about setting a disklabel &#8211; tell it to create (since you have no data to lose on the drive at this point anyway!)</p>
<p>The create new partition screen will look just the same as before, only this time you will want to specify the filesystem type you want to use. Apply all the pending operations and wait for the formatting process &#8211; it can take quite a while, especially for large drives.</p>
<h3>Mounting the encrypted drive</h3>
<p>Having successfully set up encryption and created a filesystem, we&#8217;re almost ready to to mount the drive and begin using it! (Of course, this is still assuming you&#8217;re using USB. If you&#8217;re using eSATA then this won&#8217;t work as easily &#8211; that will come in a later post!)</p>
<p>Shut down the computer, disconnect the drive, and reboot. Once you&#8217;re back up and logged in, reconnect the drive and Gnome should prompt you for the passphrase and then mount automatically.</p>
<p><a href="http://www.mattmckimmy.com/blog/wp-content/uploads/2009/09/unlock.jpg"><img class="aligncenter size-full wp-image-143" title="unlock" src="http://www.mattmckimmy.com/blog/wp-content/uploads/2009/09/unlock.jpg" alt="unlock" width="425" height="260" /></a></p>
<p>If you want the drive to unlock automatically on this computer, select &#8220;remember forever.&#8221;</p>
<p>After you&#8217;re unlocked and mounted, the final step is to take ownership of the drive&#8217;s root folder with a user other than your sudo/root user:</p>
<pre>sudo chown youruser:youruser /media/disk</pre>
<p>where <em>youruser</em> is the user you want to have ownership and  <em>/media/disk</em> is where gnome auto-mounted the drive.</p>
<h3>Finished!</h3>
<p>Whew! I must say it has taken far longer to write this post than it did to actually perform these operations. The longest part of the entire process was creating the ext3 filesystem. If you&#8217;re using eSATA to set up the drive it will go much faster, however as I mentioned you will have a few more steps to take before you can easily hot-swap your drive. Stay tuned for the next post in this series for that how-to &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmckimmy.com/blog/2009/09/21/setting-up-luks-encryption-on-usb-drives/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Upgraded Linux Backup</title>
		<link>http://www.mattmckimmy.com/blog/2009/08/04/upgraded-linux-backup/</link>
		<comments>http://www.mattmckimmy.com/blog/2009/08/04/upgraded-linux-backup/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 03:12:33 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[BackupPC]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[eSATA]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[LUKS]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.mattmckimmy.com/blog/?p=110</guid>
		<description><![CDATA[After taking a couple weeks to upgrade my home network backup system I feel I've learned some lessons that some other folks might benefit from. So many lessons, in fact, that one blog post seems inadequate to contain them all. With that in mind, I'm going to be authoring a series on all the steps along the way.]]></description>
			<content:encoded><![CDATA[<p>After taking a couple weeks to upgrade my home network backup system I feel I&#8217;ve learned some lessons that some other folks might benefit from. So many lessons, in fact, that one blog post seems inadequate to contain them all. With that in mind, I&#8217;m going to be authoring a series on all the steps along the way.</p>
<p>Over the next couple days (weeks?) you can expect more on the following topics:</p>
<ul>
<li><a href="http://www.mattmckimmy.com/blog/2009/08/10/new-backup-hardware/">New backup hardware: drives, enclosures, and controller card</a></li>
<li><a href="/2009/09/21/setting-up-luks-encryption-on-usb-drives/">Setting things up: LUKS encryption on external drives</a></li>
<li><a href="http://www.mattmckimmy.com/blog/2009/09/23/specifying-a-shared-mount-point-in-ubuntu-linux/">Specifying a shared mount point in Ubuntu Linux</a></li>
<li>Switching from USB to eSATA, making eSATA automount</li>
<li>Making external encrypted drives work with BackupPC</li>
</ul>
<p>As you can tell from this list I faced a lot of hoops to jump through in order to get this up and running. I&#8217;ll add links to the individual posts as I write them. Feel free to ask questions if you&#8217;ve got any!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmckimmy.com/blog/2009/08/04/upgraded-linux-backup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

