Encrypted Debian Live USB key
Posted by inputs_marmalade on Fri 6 Mar 2009 at 09:27
Handling mostly old or problematic hardware and not always having a stable internet connection, I have been struggling to find a live-cd/usb-key system which is slim, easy and fast to customize, fully encryptable and includes the debian network installer.
The great work of the Debian Live team provided me finally with a suitable solution. Debian Live is easily customizable, it shortens the time needed to create an up-to-date version of your own live-system after each customization, it is 100% pure debian, has the possibility to integrate the latest debian-netinstall image and is fully encryptable by default.
Loop-AES encrypted, standard Debian Live in four moves
I reserve about 3 GB disk space for the Debian Live image creation.
1. Install the live helper package
root@host:~# apt-get install live-helper
2. Make a dedicated directory and enter in it
root@host:~# mkdir DebianLive root@host:~# cd DebianLive
3. Prepare the configuration of the live system
root@host:~/DebianLive# lh_config -b usb-hdd -d lenny -e aes256
4. Create the image
root@host:~/DebianLive# lh_build
This takes quite long, and, if nothing fails, will prompt twice for the encryption password.
The result will be a file called binary.img which you can then copy to a usb-key with dd (remember: dd will erase all data on the whole key! Double-check wherever your usb-key is really in /dev/sda and if you have important data in it!)
root@host:~/DebianLive# dd if=binary.img of=/dev/sda bs=1M
Customization of Debian Live
The lh_config command has plenty of appendable options: man lh_config describes most of them. These options change the default configuration files created in the config/ directory by live-helper, where you could also manually edit the files. There are plenty of possibilities to intervene in the process, but here I will only introduce the most obvious ones.
The lh_config command will create a directory tree, where the some of the notable directories are:
./ |-- config | |-- (...) | |-- chroot_local-includes | |-- chroot_local-packages | |-- chroot_local-packageslists | |-- (...) `-- scripts
You can add in here whatever you want to find in your final live system image:
- add single packages (.deb) you want to install in config/chroot_local-packages/
- add lists of packages from the apt repositories in config/chroot_local-packageslists/
You can make your own or find pre-made lists in /usr/share/live-helper/lists/
You must then advice live-helper to include your own list: lh_config --packages-lists "my_package_list" - add your own files in config/chroot_local_includes/
As an example, if you want to add your modified /etc/privoxy/config file, copy it to config/chroot_local-includes/etc/privoxy/config
Note: more experienced users will notice that adding a directory tree in config/chroot_local-includes/ is not a very orthodox way to deal with directories like /home/user/ (I am not mentioning here the significance of /etc/skel/), but in my own experience it meets my requirements.
If the lh_build command fails at some point, lh_clean will clear everything but the config/ and cache/ directories. Anyway, in my experience, most failures at this point are apt-get related. Remember that you will have to run the lh_clean command before creating in a new image a directory structure that has been already used!
About sensitive data
You can either include all your private files, configuration files and secret keys in your Debian Live image or, as I personally prefer, you could store sensitive data (like /home/user/.gnupg/, /home/user/verysecret.txt or even /home/user/.mozilla/firefox/) in a loop-AES (or, depending on the encryption software you prefer, you can always include it in your packages list) encrypted container on the second partition of your usb-key. Later, either adding it manually or writing a script, you can use that sensitive data in your live system:
- syncronize this data between your home computer and the container
- copy your fresh made Debian Live binary image to a usb-key
- copy the encrypted container to the second partition of the usb-key
once you later boot from usb:
- mount the container from within the live-system
- make symbolic links of your sensitive data to the live-system (changes will be stored in your container)
Anyway, if you don't care about encryption, live-helper has an automatic function to store all the changes made in a live-session thanks to the "persistence" option.
Further informations about "persistence" and many more topics of live-helper can be found at the Debian Live homepage, notably in the Debian Live manual and in the Debian Live wiki.
Last but not least, here a very short reminder of some useful lh_config options:
-d lenny # choose the debian distribution to use [lenny|squeeze|sid] -b usb-hdd # define the image type to build [iso|net|tar|usb-hdd] -e aes256 # encrypt the root filesystem with loop-AES [aes128|aes192|aes256] --mirror-bootstrap http://192.168.100.1:3142/ftp.de.debian.org/mirror/debian/ # use your own apt-proxy/mirror/cacher --mirror-chroot http://192.168.100.1:3142/ftp.de.debian.org/mirror/debian/ # use your own apt-proxy/mirror/cacher --mirror-chroot-security http://192.168.100.1:3142/security.debian.org/ # use your own apt-proxy/mirror/cacher --mirror-binary http://ftp.de.debian.org/mirror/debian/ # added to the live system's /etc/apt/sources.list --mirror-binary-security http://security.debian.org/ # added to the live system's /etc/apt/sources.list --debian-installer enabled # include the debian network installer in your image --debian-installer-distribution lenny # choose the debian installer distribution to use [lenny|squeeze|sid] --packages-lists "my_package_list" # install the packages listed in config/chroot_locale-packageslist/my_package_list --bootstrap-flavour minimal --packages-lists "minimal" # the minimal flavour image will be about 100MB
Enjoy :)
[ Parent | Reply to this comment ]
Thanx
[ Parent | Reply to this comment ]
[ Send Message ]
[ Parent | Reply to this comment ]
thanx
[ Parent | Reply to this comment ]
[ Send Message ]
But the good thing is: you can have a new Debian Live image in a reasonable time. The way I do it, is to keep a copy of the things I have added to the "chroot_local" directories listed in the article, and I made myself a .txt file to remember the large "lh_config" command. Have a look: http://ram.squat.net/tech/live/encrypted_debian_live.html#finetun ing
Doing like this, it's only some cut'n'paste: keep a copy of the things you add in an ordered place, and you'll be able to have a new Debian Live image with a new passphrase in an hour (CPU running 1.4GHz), but with up-to-date software in it.
In my opinion, the whole good thing about Debian Live is exactly that it is faster to make a new up-to-date image than anything else I know: each time you'll add/remove something so that each time it will be more likely to be the image you really need.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Is there any way to control what architecture the image is built for? My desktop is a lowly P4 with not enough hard disk space to even install Debian (family too used to Windows). My two Debian laptops are PowerPC and AMD64 based. The computers at work are mixed x64 and amd64. I think most beneficial to me would be an image with x86 binaries, but I have no available system to do so. Is there some way to ocnfigure lh to build an image with x86 binaries on a system with a different arhcitecture?
[ Parent | Reply to this comment ]
Good luck and have fun!
[ Parent | Reply to this comment ]
An error as occured on boot
I wrote my key and i took this error:
LOOP_SET_STATUS: Invalid argument, requested cipher or key length (256 bits) not supported by kernel
Anyone can help me ?
Regards
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
http://www.debian-administration.org/article/81/Mounting_encrypte d_volumes
Make a container, mount it, fill it with your supersecret files, unmount it and copy the container to the usb key!
Same thing with dm-crypt, look in the "Encrypted image file" section of this article:
http://anonymous-proxy-servers.net/wiki/index.php/Linux_DM-Crypt
If that's too complicated you can try using Truecrypt (which, unfortunately, is not GPL software) but has a simple user interface...
Good luck!
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
--username live-user
look in the manual page of the debian live package!
[ Parent | Reply to this comment ]