When using full disk encryption with Ubuntu (opposed to homedir encryption), dm-crypt with LUKS is used for encrypting the volume. In the installer (at least on 12.04 alternate) you can choose between setting it up using a passphrase or a keyfile. I'd like to use a combination of the two; not either, but require both.
Why? Because this enhances security (two-factor); you'll need to have something and you need to know something to unlock it. Then I want to put the keyfile on a small removable storage device (USB flash drive) and only plug it in during boot time. The result should be that it is required to put in the right flash drive and provide the right passphrase to unlock the root partition.
So, put in other words, I want to be asked during boot for the passphrase to which the keyfile on an external drive is encrypted.
I see a /usr/share/initramfs-tools/hooks/cryptgnupg
helper script that may help to accomplish it, but I have no clue how to use it.
Just to avoid confusion: I am not asking for a way to add an additional key to the volume to unlock it.
I do the same thing, however I'm afraid my answer won't be satisfactory, as for various reasons I went with a completely custom Initramfs.
Instead of
GnuPG
, which is an extra binary that has to be included in the Initramfs (and in case ofGnuPG-2
, a rather complex one), I simply used what's already there. And that's obviouslydm-crypt/LUKS
.So suppose you have a
keyfile
. Preferably one with random data.Add encryption for it with LUKS (feel free to add your cipher settings of choice).
Now you have a keyfile (512 byte) and a keyfile.luks (2MB, which cryptsetup for some reason needs to write the 192k LUKS header). Since the Initramfs will be compressed anyway, that is not too bad (still smaller than
GnuPG
).Now you can decrypt the keyfile:
And you have 512 byte of random data in
/dev/mapper/lukskey
. (You may write to it if you want to change it, so we could have initialized the file with zeroes earlier.)In Initramfs
init
you could then proceed to open the real LUKS volume with it (assuming you added the key first).This approach makes GnuPG entirely superfluous, plus you get all LUKS advantages, such as multiple passphrases for the key, cipher of your choice, et cetera. Not to mention a nice (mostly regular) password prompt with multiple retries.