![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Security Discussions Discuss security flaws/updates/notices in the various Ubuntu releases. |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
A Carafe of Ubuntu
![]() Join Date: Mar 2008
Location: Oslo
Beans: 122
Ubuntu Jaunty Jackalope (testing)
|
Re: Move encrypted /boot to SD card
My problem is that I am running a Laptop at the moment, so cutting the power will just switch it to battery mode. My Power button is defaulted to 8 sec before forced shutdown.
|
|
|
|
|
|
#12 |
|
First Cup of Ubuntu
![]() Join Date: Jun 2008
Location: Australia
Beans: 10
Ubuntu 8.04 Hardy Heron
|
Re: Move encrypted /boot to SD card
Hi,
From what I understand, you've already got a Hardy setup with full encryption. You just want to use an encrypted SD card, so that you need the card in the slot and want it to prompt you for a password as well? I've managed to get my laptop to require an SD card for a keyfile. While messing around with getting this to work, I managed to come up with a script that will only boot *IF* you have the SD card in the slot. From what I understand (I'm brand new to this...) if you've already got an encrypted HDD setup, you should be able to follow the steps in a howto to make an encrypted SD card and then just change parts of the bootscript so that it looks for an encrypted SD card. In other words. No need to reformat your entire system. 1) Just create an encrypted SD card. 2) Generate a keyfile. 3) Set the system to accept the keyfile. 4) Change the bootscript to look for the keyfile on the SD card on boot. |
|
|
|
|
|
#13 |
|
A Carafe of Ubuntu
![]() Join Date: Mar 2008
Location: Oslo
Beans: 122
Ubuntu Jaunty Jackalope (testing)
|
Thank you Chunky for reviving my interest (though it barely decreased in one day) in setting this up. Actually, reading through your guide was what had initially piqued my intest (the guide can be found here ).
I must admit, however, that reading through that guide surely made me feel like much more of a novice than you. If you could help guide me through this process, it would be greatly appreciated. It seems as though this may be something interesting for more than just us two. I added the modules as indicated. Next I ran: Code:
fdisk -l Code:
Disk /dev/mmcblk0: 1015 MB, 1015808000 bytes
32 heads, 63 sectors/track, 984 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 984 991747+ 6 FAT16
I read through http://wejn.org/how-to-make-password...ryptsetup.html to get some idea of how it works. But I stopped short of actually working with it since I am unsure of how it will play into this application. |
|
|
|
|
|
#14 | |||
|
First Cup of Ubuntu
![]() Join Date: Jun 2008
Location: Australia
Beans: 10
Ubuntu 8.04 Hardy Heron
|
Re: Move encrypted /boot to SD card
Sorry for the tardy reply Tubes... Real life got in the way.
I really am very new to linux in general, but I hope between the two of us we can get this to work. First there's one important thing that I want to check. 1) Your HDD is already encrypted with LUKS (which is what I'm assuming because you've mentioned that you don't want to start from scratch again.) ***IMPORTANT*** I haven't actually tested this on my system yet, but from what I understand this should be what you need to get it to work on yours. If it is, we can then start this (I've taken bits from both http://mazeoflies.com/articles/2008/...h-external-key and http://wejn.org/how-to-make-password...ryptsetup.html) So we're going to prepare an encrypted SD Card to hold the keyfile for the HDD. We're not going to do this from the Live CD, but from the booted system. So since you know which device you're going to use /dev/mmcblk0p1 we can go straight to filling the SD card with random bits Code:
dd if=/dev/urandom of=/dev/mmcblk0p1 Next we format the SD card with Code:
cryptsetup luksFormat --hash=sha512 --cipher=aes-cbc-essiv:sha256 --key-size=256 /dev/mmcblk0p1 Now we mount the SD Card Code:
cryptsetup luksOpen /dev/mmcblk0p1 cryptkeys Code:
mkfs.ext2 /dev/mapper/cryptkeys From http://wejn.org/how-to-make-password...ryptsetup.html Quote:
But because we're using an SD card we also have to add Code:
mmc_core ricoh_mmc mmc_block sdhci (since we formatted the SD card as ext2 we probably don't need all the FAT filesystem modules, but just the SD card ones... but it won't hurt keeping them in anyway) back to the howto Quote:
We need to use a keyscript that mounts the encrypted SD card and then loads the required file from it. I'm going to modify my SD card keyscript to make it work. Code:
#!/bin/sh # Part of passwordless cryptofs setup in Debian Etch. # See: http://wejn.org/how-to-make-passwordless-cryptsetup.html # Author: Wejn <wejn at box dot cz> # # Updated by Rodolfo Garcia (kix) <kix at kix dot com> # For multiple partitions # http://www.kix.es/ # # Updated by Cromwel Flores <cromwel dot flores at gmail dot com> # For Encrypted MMC/SD card using code from http://mazeoflies.com/files/keyscript # # Disk partition type (ext2 or vfat) PARTTYPE=ext2 # Key file in the disk KEYFILE=root.key # # # # # CODE # # # # # MD=/tmp-mount if [ "x$1" = "x" -o "x$1" = "xnone" ]; then KEYF=$KEYFILE else KEYF=$1 fi USBLOAD=0 FSLOAD=0 MMCLOAD=0 cat /proc/modules | busybox grep usb_storage >/dev/null 2>&1 USBLOAD=$? cat /proc/modules | busybox grep $PARTTYPE >/dev/null 2>&1 FSLOAD=$? cat /proc/modules | busybox grep mmc >/dev/null 2>&1 MMCLOAD=$? #Check if all the required modules have been already loaded if [ $USBLOAD -gt 0 ] || [ $FSLOAD -gt 0 ] || [ $MMCLOAD -gt 0 ]; then modprobe usb_storage modprobe mmc_core modprobe ricoh_mmc modprobe mmc_block modprobe sdhci modprobe $PARTTYPE fi OPENED=0 ls -d /sys/block/sd* >/dev/null 2>&1 SDS=$? if [ $SDS -eq 0 ]; then echo "Trying to get the keyfile from physical keychain ..." >&2 mkdir -p $MD #*** [Modified from http://mazeoflies.com/files/keyscript] *** # open the SD card, with 3 retries on the password count=0 openstat=0 while [ $count -lt 3 ]; do count=$(( $count + 1 )) if [ ! -e /dev/mapper/bootkey ]; then echo -n "Enter Passphrase ==> " > /dev/console cryptsetup luksOpen /dev/mmcblk0p1 bootkey > /dev/null 2>&1 openstat=$? else break fi done # check for failure if [ $openstat -ne 0 ]; then echo "Failed to open device" > /dev/console exit 1 #*** [/Modified from http://mazeoflies.com/files/keyscript] *** else # Try getting file from SD Card echo "> Looking for keyfile in SD Card ..." >&2 mount /dev/mapper/bootkey $MD -t $PARTTYPE -o ro 2>/dev/null if [ -f $MD/$KEYF ]; then cat $MD/$KEYF umount $MD 2>/dev/null OPENED=1 else echo "> Could not find keyfile in SD Card ..." >&2 fi fi umount $MD 2>/dev/null rmdir $MD 2>/dev/null fi Now we return to the howto Quote:
The way things are setup right now, you should be prompted for the password for your SD Card. You have 3 tries to get it right. If you mess up or it can't find the keyfile on the SD Card your machine won't allow you to decrypt your HDD. You'll have to restart and press esc when grub comes up and choose the safe boot option that will prompt you for your HDD password instead of trying to get the key from the SD card. Once you're sure that everything is working, then you can go ahead and delete the HDD password using cryptsetup luksDelKey (remember that if you do this and lose your SD card, you are so outta luck...) I'm not gonna have stable net access for a week or so after Friday, but drop me a pm and let me know how things work out for you. Good luck. |
|||
|
|
|
|
|
#15 |
|
I Want My $2!!
![]() Join Date: Mar 2007
Location: Denver, CO
Beans: 7,077
Ubuntu 8.10 Intrepid Ibex
|
Re: Move encrypted /boot to SD card
To to be rude, but I about cra**ed my pants when I saw the Chucky had posted a rather detailed, informative, instructional reply. Holy cow -- is the sky falling?
|
|
|
|
|
|
#16 |
|
A Carafe of Ubuntu
![]() Join Date: Mar 2008
Location: Oslo
Beans: 122
Ubuntu Jaunty Jackalope (testing)
|
Re: Move encrypted /boot to SD card
I certainly did not expect you to do this! Thank you very much for the write-up. I had been chasing this down (staring at your script for way too long, trying to figure it out), and ran into the same problem I get here:
When I enter: Code:
cryptsetup luksFormat --hash=sha512 --cipher=aes-cbc-essiv:sha256 --key-size=256 /dev/mmcblk0p1 Code:
cryptsetup luksFormat --hash=sha512 --cipher=aes-cbc-essiv:sha256 --key-size=256 /dev/mmcblk0p1 Using cat /proc/crypto lists sha256 as supported. I just thought I would update you as far as I have gotten with this. I'll update more as I go along. UPDATE: Using: Code:
cryptsetup -c aes-cbc-essiv:md5 -y -s 8 luksFormat /dev/ Last edited by Tubes6al4v; July 9th, 2008 at 09:04 PM.. |
|
|
|
|
|
#17 | |
|
First Cup of Ubuntu
![]() Join Date: Jun 2008
Location: Australia
Beans: 10
Ubuntu 8.04 Hardy Heron
|
Quote:
Or am I being mixed up with someone else? @Tubes6al4v You're welcome. =D Although, all I really did was just cut and paste selected bits from two other walkthrough to try and get this thing to work. I don't actually know much about how cryptsetup works... All that line is supposed to do is to make your SD card encrypted... So you should be able to do that with TrueCrypt but I'm not familiar with TrueCrypt so I don't know if the mishmash of a keyscript I put together will work properly with it or not. Good luck and keep us posted. |
|
|
|
|
|
|
#18 |
|
First Cup of Ubuntu
![]() Join Date: Jun 2008
Location: Australia
Beans: 10
Ubuntu 8.04 Hardy Heron
|
Re: Move encrypted /boot to SD card
Actually, while I'm thinking about it what happens if you try this?
(I'm at work atm, so I can't test this out.) Code:
cryptsetup luksFormat /dev/mmcblk0p1 Also I'm not sure if the card is supposed to be unmounted before you do this. |
|
|
|
|
|
#19 |
|
A Carafe of Ubuntu
![]() Join Date: Mar 2008
Location: Oslo
Beans: 122
Ubuntu Jaunty Jackalope (testing)
|
Re: Move encrypted /boot to SD card
Final Reply Before bed:
I dropped the "p1" off of /dev/mmcblk0p1" And that got me through to the end. When I attempt to "sudo update-initramfs -u all" I get this response: Code:
update-initramfs: Generating /boot/initrd.img-2.6.24-18-generic cryptsetup: WARNING: target sda5_crypt has an invalid keyscript, skipped cryptsetup: WARNING: target sda5_crypt has an invalid keyscript, skipped |
|
|
|
|
|
#20 |
|
First Cup of Ubuntu
![]() Join Date: Jun 2008
Location: Australia
Beans: 10
Ubuntu 8.04 Hardy Heron
|
Re: Move encrypted /boot to SD card
=D Awesome.
Umm... Did you set the permissions correctly for the keyscript? (again from memory) Code:
sudo chmod a+x /usr/local/sbin/crypto-usb-key.sh |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|