Let's say I use LUKS for all my system except for /boot and I have my /home/user directory encrypted as well. In the context of the security of my user account (Which is more than less isolated from root) should I create another encrypted container to store my key files for the purpose of quick mounting of encrypted drives?

At first I wanted to have my drives auto-mounted when I login to my user account but that seems less secure. Would it be better to encrypt a thumb drive and store my keys on it so that I have to decrypt/mount the thumb drive first?

I see this sort of thing suggested here and here but that then begs the question: If I'm decrypting a drive containing keyfiles in the context of my user account, is it anymore secure than if I'd stored them somewhere in /home/user?


Storing a keyfile in the same location as the encrypted volume is useless. Encryption is only useful if the decryption key is stored separately from the encrypted volume: in your head, on a removable device (USB key, smartcard, …), etc.

(There is one way in which encryption is still useful with the key stored in the same location: quick wipe. You can effectively wipe the data on an encrypted volume by wiping the key, you don't need to wipe the whole volume. But that's marginal.)

To use full-disk encryption, you need to input the decryption key at boot time, one way or another. So you either need to type a passphrase, or insert a removable device containing the keyfile.

Encryption is only useful against someone who steals the disk (with or without the rest of the computer). It doesn't protect against software that's running on the computer: the operating system's isolation and access control mechanisms do that. Once you've booted the system, the protection against stealing the computer (including temporarily “stealing” the computer by typing at the keyboard while you're away) is screen locking.

If this is a single-user system then there are not many scenarios where additional encryption beyond the full-disk encryption is useful. Either the attacker has access to your account and they can access all your files, or the attacker doesn't have access to your account and they can't access anything except by putting the disk in their computer, which leaves them with an encrypted disk and (assuming the key didn't get stolen with the disk) no way to decrypt it.

There can be an advantage in having a second layer of encryption if there are files that you consider to be especially confidential and you don't use them often. If that's the case then encrypt them with a different passphrase. Then, if your computer is infected by malware, then the malware won't be able to access all your most confidential files, only the ones that for which you entered the decryption key before you noticed the malware.

Another advantage in a second layer of encryption is to protect against relatively sophisticated attackers who steal the computer while it's still running and extract the key from RAM. You can protect against this by configuring your computer to unmount decrypted volumes while you aren't in front of the computer. This requires a second layer of encryption (unless you skip full disk encryption and only encrypt your personal files) because the system files have to remain accessible (the decryption software and the interface to read the key have to be available). I believe that iOS and Android are heading towards such a setup, if they haven't reached this point yet, but I don't know of an easy way to set this up under Linux.

Regarding the aspect of storing the keyfiles themselves on an encrypted container, that only makes sense if the encrypted container is protected by a passphrase rather than another keyfile, and it's only useful if the container is a removable drive. Protecting the removable drive with a passphrase means that if someone steals the drive but can't guess your passphrase, they won't be able to decrypt your data. But once again, if the keyfiles are on the same media as the data, then there's no benefit to having the keyfiles in the first place.

  • I didn't mean store the keys on the medium they encrypt; rather, store them on a separate encrypted medium (My /home/user directory). I've since however decided to store them on a removable drive (Encrypted with a passphrase). The point of the keyfiles is so I don't have to type in a passphrase for all my other drives, I just have to type in 1 passphrase to get to my keyfiles. – xendi Feb 10 '17 at 15:11
  • I'll accept the answer though since it contains what I did and has useful info. – xendi Feb 10 '17 at 15:13
  • @xendi Ah, ok. Then you can replace “removable device” by “main disk” and “your disk” with “your other disks”, and storing the keyfile on the main disk is a viable solution. However, if the other disks aren't removable, it would be just as secure and simpler to use the same passphrase everywhere. – Gilles 'SO- stop being evil' Feb 10 '17 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.