Encryption using Offline Keys

Nvious1

Explorer
Joined
Jul 12, 2018
Messages
67
I am setting up a new pool and plan to use Encryption. I was reading over the docs here. The doc references multiple ways to keep the keys. I am interested in how this one is achieved?
  • Key not stored locally: the encrypted pool is not accessible until the FreeNAS® administrator provides the key. If a passphrase is set on the key, it must also be entered before the encrypted pool can be accessed (two factor authentication)

It seems the default setup is to initially enable encryption with no passphrase. Adding a passphrase, simple requires you to provide that to unlock the pool. How do I get to the point where the key is not stored locally and I need to provide it manually each time to unlock the pool?
 

Nvious1

Explorer
Joined
Jul 12, 2018
Messages
67
No I haven't at this time although I haven't put much effort into looking into it other than this posting.
 
Joined
Oct 18, 2018
Messages
969
No I haven't at this time although I haven't put much effort into looking into it other than this posting.
There is a great explanation out there somewhere on this which I couldn't find so I'll try to summarize to the best of my knowledge.

Whenever you encrypt a pool with FreeNAS it uses geli encryption. Each disk gets a master key written to that disk which is, itself, encrypted and requires a key to use, this second key is called the User key and is the one you really care about. Without the User key, the master key is useless. There can be two user keys. The first and default is called User key 0 (at least I think that is the name). This one is written to the FreeNAS boot drive by default and is not password protected by default. If you set a password on the encrypted pool what you're doing is adding a password to User key 0. This way you can only use it with the password.

You can, of course, fish around in your system and find this User key 0 and move it. In my system it is found in /data/geli If you do, when you try to decrypt your disk you will get an error. I know because I've tried. If you then put the file back and try again it will work. I've tried this as well.

There is a second User key which you can create, the so-called recovery key. This is NEVER stored anywhere on your boot or storage drives by design. Geli supports password protecting this key as well but to my knowledge FreeNAS does not support this feature. The recovery key should be securely stored somewhere off of your system and should only be used in a recovery scenario. If someone has your recovery key they can get into your pool without a password!

In order to decrypt your pool you only need either User key 0 or User key 1 (the recovery key). The purpose of the recovery key is if you forget the password to User key 0.

Do note that it is important that you store a backup of your key and your recovery key. The reason is that if you have to reinstall the OS you'll need a key to get access to your encrypted pool. Remember the master key lives on the drives but you have to have a User key to make use of the master key. I don't believe either User key is stored in a config backup (by design as a security feature) so simply keeping a backup of your system config is not enough. Also, when you replace a disk in an encrypted pool the manual instructs you as follows.

During step 3, there will be a prompt to enter and confirm the passphrase for the pool. Enter this information, then click REPLACE DISK. Immediately restore the encryption keys to the pool. If this additional step is not performed before the next reboot, access to the pool might be permanently lost.

  1. Highlight the pool that contains the recently replaced disk and click Add Recovery Key to save the new recovery key. The old recovery key will no longer function, so it can be safely discarded.

This bit is a little confusing. If I understand correctly it is saying that when you replace a disk in an encrypted pool the master key for the new drive must be created which means regenerating the user keys to decrypt that new master key. This process is required so you should rekey your pool and make backups of those keys right away.

I hope this helps some. I'm writing from memory for the technical explanations. I'm just starting to do some testing of my own for replacing drives in encrypted pool and moving them between FreeNAS instances.

If I manage to find that page with the nice explanation about how geli encryption works I'll be sure to update my post. If someone more knowledgeable than I finds flaws in what I've written let me know and I'll happily adjust. :)
 

Nvious1

Explorer
Joined
Jul 12, 2018
Messages
67
@PhiloEpisteme your reply is greatly appreciated. It seems like if I find this userkey 0 and move it off the system, it will achieve the offline encryption key I am looking for. That said, I realize I will need to put the key back on the system to unlock the pool and to your note, I will also need to make sure I save off an update of the key if I ever have to replace a disk and a rekey event occurs.
 
Joined
Oct 18, 2018
Messages
969
@PhiloEpisteme your reply is greatly appreciated. It seems like if I find this userkey 0 and move it off the system, it will achieve the offline encryption key I am looking for. That said, I realize I will need to put the key back on the system to unlock the pool and to your note, I will also need to make sure I save off an update of the key if I ever have to replace a disk and a rekey event occurs.
And you should absolutely test those things on encrypted pools BEFORE you put sensitive data on them.

I would recommend that you make sure you can do the following before adding any sensitive data to your pools.

  1. Encrypt your pool, remove the key, try to decrypt it, it should fail. Put the key back and see it decrypt.
  2. Then, remove the key, reboot the computer, try to decrypt and see it fail. Put the key back and see it pass.
  3. Then, go through the HDD replacement procedure on an encrypted pool and be sure you know how to do it. Reboot the computer after you're done and try to decrypt the pool, did it work? If it didn't you likely forgot to rekey the pool and save the pool.
  4. Finally, create an encrypted pool, back up the key and config, and then either move the disks to another FreeNAS box or use a fresh install. Import the old configs and the key, can you decrypt it?

Keep in mind that decryption is just as good at keeping you out as anyone else if you lose the key or can't remember the password and don't have the recovery key. And if you mess up it isn't a problem you can throw money at. Data recovery doesn't have until the head death of the universe to decrypt your drive and even if they did you wouldn't have enough money to afford that service. Backing up your key is extremely important and keeping it organized is too. When you rekey due to replacing a drive etc you'll want to be sure you only keep the correct key around and don't accidentally lose it.

:) Hopefully this helps.
 
Top