Linux encryption - encrypted directories
I've always been fond of storing a directory structure encrypted in a file (ala TrueCrypt or PGPDisk). I borrowed instructions from here.
Create the raw file to contain your encrypted data.
dd if=/dev/urandom of=~/encrypted.bin bs=1M count=100
Find the next available loop device and map this file to it.
losetup -f
losetup /dev/loop0 ~/encrypted.bin
Setup the crypto filesystem, open it with the correct password, format the partition ext3, and finally mount the newly created filesystem as /mnt/tmp
cryptsetup --verbose --cipher "aes-cbc-essiv:sha256" --key-size 256 --verify-passphrase luksFormat /dev/loop0
cryptsetup luksOpen /dev/loop0 my-crypt
mkfs.ext3 /dev/mapper/my-crypt
mount -t ext3 -o rw,defaults /dev/mapper/my-crypt /mnt/tmp/
When you're all done, and want to secure all the files do the following. Umount the filesystem, close the crypto link, remove the file to loopback device link.
umount /mnt/tmp/
cryptsetup luksClose my-crypt
losetup -d /dev/loop0