You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
3.5 KiB

  1. <section xmlns="http://docbook.org/ns/docbook"
  2. xmlns:xlink="http://www.w3.org/1999/xlink"
  3. xmlns:xi="http://www.w3.org/2001/XInclude"
  4. version="5.0"
  5. xml:id="sec-luks-file-systems">
  6. <title>LUKS-Encrypted File Systems</title>
  7. <para>
  8. NixOS supports file systems that are encrypted using
  9. <emphasis>LUKS</emphasis> (Linux Unified Key Setup). For example, here is how
  10. you create an encrypted Ext4 file system on the device
  11. <filename>/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d</filename>:
  12. <screen>
  13. # cryptsetup luksFormat /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d
  14. WARNING!
  15. ========
  16. This will overwrite data on /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d irrevocably.
  17. Are you sure? (Type uppercase yes): YES
  18. Enter LUKS passphrase: ***
  19. Verify passphrase: ***
  20. # cryptsetup luksOpen /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d crypted
  21. Enter passphrase for /dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d: ***
  22. # mkfs.ext4 /dev/mapper/crypted
  23. </screen>
  24. To ensure that this file system is automatically mounted at boot time as
  25. <filename>/</filename>, add the following to
  26. <filename>configuration.nix</filename>:
  27. <programlisting>
  28. <link linkend="opt-boot.initrd.luks.devices._name__.device">boot.initrd.luks.devices.crypted.device</link> = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d";
  29. <xref linkend="opt-fileSystems"/>."/".device = "/dev/mapper/crypted";
  30. </programlisting>
  31. Should grub be used as bootloader, and <filename>/boot</filename> is located
  32. on an encrypted partition, it is necessary to add the following grub option:
  33. <programlisting><xref linkend="opt-boot.loader.grub.enableCryptodisk"/> = true;</programlisting>
  34. </para>
  35. <section xml:id="sec-luks-file-systems-fido2">
  36. <title>FIDO2</title>
  37. <para>
  38. NixOS also supports unlocking your LUKS-Encrypted file system using a FIDO2 compatible token. In the following example, we will create a new FIDO2 credential
  39. and add it as a new key to our existing device <filename>/dev/sda2</filename>:
  40. <screen>
  41. # export FIDO2_LABEL="/dev/sda2 @ $HOSTNAME"
  42. # fido2luks credential "$FIDO2_LABEL"
  43. f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7
  44. # fido2luks -i add-key /dev/sda2 f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7
  45. Password:
  46. Password (again):
  47. Old password:
  48. Old password (again):
  49. Added to key to device /dev/sda2, slot: 2
  50. </screen>
  51. To ensure that this file system is decrypted using the FIDO2 compatible key, add the following to <filename>configuration.nix</filename>:
  52. <programlisting>
  53. <link linkend="opt-boot.initrd.luks.fido2Support">boot.initrd.luks.fido2Support</link> = true;
  54. <link linkend="opt-boot.initrd.luks.devices._name__.fido2.credential">boot.initrd.luks.devices."/dev/sda2".fido2.credential</link> = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7";
  55. </programlisting>
  56. You can also use the FIDO2 passwordless setup, but for security reasons, you might want to enable it only when your device is PIN protected, such as <link xlink:href="https://trezor.io/">Trezor</link>.
  57. <programlisting>
  58. <link linkend="opt-boot.initrd.luks.devices._name__.fido2.passwordLess">boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess</link> = true;
  59. </programlisting>
  60. </para>
  61. </section>
  62. </section>