How To

Create an Encrypted Bootable Flashdrive

Information security is becoming increasingly important, but why pay extra for a flash drive with built-in encryption when you can quickly and easily do it yourself using free, open source tools.

This tutorial will show you how to use Ubuntu 9.10 and some of the utilities it ships with to create a bootable USB flash drive with an encrypted partition. The encrypted partition will be directly accessible through any Linux machine with dmcrypt installed or through it's own bootable copy of Ubuntu Linux so if there isn't a Linux machine available you can just boot from the drive an access your data securly.

Before you begin you will need:

  • A flash drive with a capacity of at least 2GB (this tutorial uses an 8GB drive. Adjust accordingly for your drive size)
  • A computer running Ubuntu 9.10
  • A copy of the Ubuntu 9.10 32-bit desktop edition iso file
  • GParted installed on your Ubuntu machine

Step 1: Delete all data from the flash drive

This may seem a bit paranoid, but you want to make sure all data that has been stored on the drive is wiped clean. This command will overwrite the entire drive with zeros. Replace /dev/sdx with the actual location of your flash drive. BE VERY CAREFUL using this command. If you point it at the wrong drive (like say, the drive with your /boot partition or /home partition) it will irreversibly destroy all data on the drive starting with the MBR.

sudo dd if=/dev/zero of=/dev/sdx

Let it run until it's complete (this will take a while on larger drives)

Step 2: Partition the drive with GParted

Create a 4GB partition formatted vfat at the beginning of the drive and click Apply Changes

GParted

Step 3: Create an encrypted partition using Disk Utility (System->Administration->Disk Utility)

Select the free space on your flash drive
Set a label (optional but recommended)
Select ext4 as the filesystem
Check the encrypt underlying device box
Click create
Set your passphrase
Click create

Disk Utility

Step 4: Install Ubuntu on the flashdrive

Open the USB Startup Disk Creator (System->Administration->USB Startup Disk Creator)
Select your iso file under source disk image
Select the fat partition you created in Step 2
Set Stored in reserved extra space to the maximum allowed
Click Make startup disk (again, this will take a while on larger drives)

Make Startup Disk

Step 5: Boot from the flash drive and finalize your install

Mount the encrypted drive by clicking Places->4.1GB Media
Enter your password to unlock the drive. Make sure to never select Remember Forever . We installed a persistent filesystem on the flash drive so it will save files, settings and passwords to the drive and remember them between boots.

The first time you mount it the system may refuse to open the drive. If this is the case open a terminal and enter the command:

sudo chown ubuntu:ubuntu /media/data

Where data is the label you used for your encrypted partition in step 3
Reboot the system

Mount Drive

Now you can carry sensitive data around with you and relax knowing it is easily accessible and totally secure. (you did use a strong password, right?)

Convert Your Filesystem from ext3 to ext4

Ubuntu 9.04 the "Jaunty Jackalope" was released today. It's got a lot of great new features including a new notification system on the desktop and support for cloud computing with full support for the Amazon EC2 API through the Eucalyptus project on the server.

One of the big features of this release is support for the recently released ext4 filesystem. Ext4 has a ton of great features and helps bring a modern filesystem implementation to Linux. One of the great features of ext4 is the ability to convert an existing ext3 filesystem to ext4 without losing any data. If you are thinking of upgrading your Ubuntu 8.10 machine to Ubuntu 9.04 and want to upgrade your filesystem as well, here's how to do it.

First you're going to want to upgrade your system from Ubuntu 8.10 to 9.04 if you haven't already done so. Follow the instructions here to perform the upgrade.

NOTE :: Make sure to back up all important data before upgrading the distribution or the filesystem

Next, boot the computer from the Ubuntu 9.04 Desktop CD Once you are booted into the live environment, run the following command replacing /dev/DEV with the drive partition that you want to upgrade.

tune2fs -O extents,uninit_bg,dir_index /dev/DEV

NOTE :: the -O is the capital letter O, not zero

You then need to run fsck to fix up some on-disk structures that tune2fs has modified.

e2fsck -fD /dev/DEV

Next, mount the drive

mount -t ext4 /dev/DEV /mnt

Edit fstab and change ext3 to ext4 on the drive you upgraded

UUID=xxxx / ext4 relatime,errors=remount-ro 0 1

Finally, you need to run grub-install on your new partition. The version of grub that shipped with Ubuntu 8.10 cannot boot from ext4 partitions so if you skip this step, your computer won't boot.

grub-install /dev/DEV --root-directory=/mnt --recheck

Now reboot the computer and enjoy your new ext4 filesystem.

NOTE :: By enabling the extents feature new files will be created in extents format, but this will not convert existing files to use extents. Non-extent files can be transparently read and written by Ext4.

Create a Simple VPN Using SSH and Gnome Proxy Settings

Are you one of those people who worries about someone sniffing your wireless traffic at a coffee shop? Well fear not, because today I'm going to show you how to set up a quick and dirty VPN to secure your packets (and get around those pesky web filters too).

Here's what you'll need:

  • A dynamic DNS account set up and pointed to your home broadband connection
  • A computer at home running an OpenSSH server with the SSH port forwarded to said computer
  • A laptop with the OpenSSH client installed and running Gnome desktop (any recent distro will do)

The dynamic DNS setup is outside the scope of this tutorial, but episode 90 of Systm on Revision3 will show you how to configure it if you don't already know.

In this example, we'll be using Ubuntu Linux, but all the commands (with the exception of the command to install OpenSSH server) will work on all recent distros.

First you need to install OpenSSH server on your home computer. Make sure you have strong passwords set for all user accounts on this machine.

sudo apt-get install ssh

Next, set up port forwarding on your router to pass all traffic on port 22 to the computer on which you just installed OpenSSH server. That's it for your home computer.

Using your laptop, connect to an untrusted or filtered internet connection in your favorite bar or coffee shop. Now you can quickly and easily establish a secure connection back to your home ISP using the following steps:

Open a terminal window and enter in the following command:

ssh -D 9999 user@your.dyndnsaddress.com

Where user is the user name to log in to your home computer. This sets up an SSH socks proxy connection to your home computer on port 9999 of your local machine.

Finally, Click System -> Preferences -> Network Proxy and enter the following settings: Proxy Settings

Once this is set all applications that use Gnome Proxy Settings will automatically use the proxy connection. Your packets are now safely encrypted all the way to your home internet connection.

Enjoy!