2008-11-09

Encrypting your /tmp partition

In my last post I explained how to encrypt the SWAP partition. Today I'm going to show how to encrypt the /tmp partition. First of all it is necessary to install the cryptsetup tool.

apt-get install cryptsetup

Let us assume that /dev/sda7 should become our encrypted /tmp partition. We will start and write a lot of random data into this partition. This will protect against some kind of cryptoanalysis attacks.

dd if=/dev/urandom of=/dev/sda7

Depending on the size of your /tmp partition you should go and drink one or more coffees. This step will take some time.

Next we setup the cryptography device using cryptsetup:

cryptsetup --key-file /dev/urandom --key-size 128 create ctmp /dev/hda7

Finnaly we modify /etc/crypttab and /etc/fstab:

/etc/crypttab:
ctmp /dev/sda7 /dev/urandom tmp,chiper=aes-cbc-essiv:sha256,size=128,hash=ripemd160

/etc/fstab:
/dev/mapper/ctmp none ext2 nodev,nosuid 0 2

Now restart your computer and your /tmp partition should be encrypted.