1CRYPTTAB(5)                        crypttab                        CRYPTTAB(5)
2
3
4

NAME

6       crypttab - Configuration for encrypted block devices
7

SYNOPSIS

9       /etc/crypttab
10

DESCRIPTION

12       The /etc/crypttab file describes encrypted block devices that are set
13       up during system boot.
14
15       Empty lines and lines starting with the "#" character are ignored. Each
16       of the remaining lines describes one encrypted block device. Fields are
17       delimited by white space.
18
19       Each line is in the form
20
21           volume-name encrypted-device key-file options
22
23       The first two fields are mandatory, the remaining two are optional.
24
25       Setting up encrypted block devices using this file supports four
26       encryption modes: LUKS, TrueCrypt, BitLocker and plain. See
27       cryptsetup(8) for more information about each mode. When no mode is
28       specified in the options field and the block device contains a LUKS
29       signature, it is opened as a LUKS device; otherwise, it is assumed to
30       be in raw dm-crypt (plain mode) format.
31
32       The four fields of /etc/crypttab are defined as follows:
33
34        1. The first field contains the name of the resulting volume with
35           decrypted data; its block device is set up below /dev/mapper/.
36
37        2. The second field contains a path to the underlying block device or
38           file, or a specification of a block device via "UUID=" followed by
39           the UUID.
40
41        3. The third field specifies an absolute path to a file with the
42           encryption key. Optionally, the path may be followed by ":" and an
43           /etc/fstab style device specification (e.g. starting with "LABEL="
44           or similar); in which case the path is taken relative to the
45           specified device's file system root. If the field is not present or
46           is "none" or "-", a key file named after the volume to unlock (i.e.
47           the first column of the line), suffixed with .key is automatically
48           loaded from the /etc/cryptsetup-keys.d/ and /run/cryptsetup-keys.d/
49           directories, if present. Otherwise, the password has to be manually
50           entered during system boot. For swap encryption, /dev/urandom may
51           be used as key file, resulting in a randomized key.
52
53           If the specified key file path refers to an AF_UNIX stream socket
54           in the file system, the key is acquired by connecting to the socket
55           and reading it from the connection. This allows the implementation
56           of a service to provide key information dynamically, at the moment
57           when it is needed. For details see below.
58
59        4. The fourth field, if present, is a comma-delimited list of options.
60           The supported options are listed below.
61

KEY ACQUISITION

63       Six different mechanisms for acquiring the decryption key or passphrase
64       unlocking the encrypted volume are supported. Specifically:
65
66        1. Most prominently, the user may be queried interactively during
67           volume activation (i.e. typically at boot), asking them to type in
68           the necessary passphrase(s).
69
70        2. The (unencrypted) key may be read from a file on disk, possibly on
71           removable media. The third field of each line encodes the location,
72           for details see above.
73
74        3. The (unencrypted) key may be requested from another service, by
75           specifying an AF_UNIX file system socket in place of a key file in
76           the third field. For details see above and below.
77
78        4. The key may be acquired via a PKCS#11 compatible hardware security
79           token or smartcard. In this case an encrypted key is stored on
80           disk/removable media, acquired via AF_UNIX, or stored in the LUKS2
81           JSON token metadata header. The encrypted key is then decrypted by
82           the PKCS#11 token with an RSA key stored on it, and then used to
83           unlock the encrypted volume. Use the pkcs11-uri= option described
84           below to use this mechanism.
85
86        5. Similar, the key may be acquired via a FIDO2 compatible hardware
87           security token (which must implement the "hmac-secret" extension).
88           In this case a (during enrollment) randomly generated key is stored
89           on disk/removable media, acquired via AF_UNIX, or stored in the
90           LUKS2 JSON token metadata header. The random key is hashed via a
91           keyed hash function (HMAC) on the FIDO2 token, using a secret key
92           stored on the token that never leaves it. The resulting hash value
93           is then used as key to unlock the encrypted volume. Use the
94           fido2-device= option described below to use this mechanism.
95
96        6. Similar, the key may be acquired via a TPM2 security chip. In this
97           case a (during enrollment) randomly generated key — encrypted by an
98           asymmetric key derived from the TPM2 chip's seed key — is stored on
99           disk/removable media, acquired via AF_UNIX, or stored in the LUKS2
100           JSON token metadata header. Use the tpm2-device= option described
101           below to use this mechanism.
102
103       For the latter five mechanisms the source for the key material used for
104       unlocking the volume is primarily configured in the third field of each
105       /etc/crypttab line, but may also configured in /etc/cryptsetup-keys.d/
106       and /run/cryptsetup-keys.d/ (see above) or in the LUKS2 JSON token
107       header (in case of the latter three). Use the systemd-cryptenroll(1)
108       tool to enroll PKCS#11, FIDO2 and TPM2 devices in LUKS2 volumes.
109

SUPPORTED OPTIONS

111       The following options may be used in the fourth field of each line:
112
113       cipher=
114           Specifies the cipher to use. See cryptsetup(8) for possible values
115           and the default value of this option. A cipher with unpredictable
116           IV values, such as "aes-cbc-essiv:sha256", is recommended. Embedded
117           commas in the cipher specification need to be escaped by preceding
118           them with a backslash, see example below.
119
120       discard
121           Allow discard requests to be passed through the encrypted block
122           device. This improves performance on SSD storage but has security
123           implications.
124
125       hash=
126           Specifies the hash to use for password hashing. See cryptsetup(8)
127           for possible values and the default value of this option.
128
129       header=
130           Use a detached (separated) metadata device or file where the LUKS
131           header is stored. This option is only relevant for LUKS devices.
132           See cryptsetup(8) for possible values and the default value of this
133           option.
134
135           Optionally, the path may be followed by ":" and an /etc/fstab
136           device specification (e.g. starting with "UUID=" or similar); in
137           which case, the path is relative to the device file system root.
138           The device gets mounted automatically for LUKS device activation
139           duration only.
140
141       keyfile-offset=
142           Specifies the number of bytes to skip at the start of the key file.
143           See cryptsetup(8) for possible values and the default value of this
144           option.
145
146       keyfile-size=
147           Specifies the maximum number of bytes to read from the key file.
148           See cryptsetup(8) for possible values and the default value of this
149           option. This option is ignored in plain encryption mode, as the key
150           file size is then given by the key size.
151
152       keyfile-erase
153           If enabled, the specified key file is erased after the volume is
154           activated or when activation fails. This is in particular useful
155           when the key file is only acquired transiently before activation
156           (e.g. via a file in /run/, generated by a service running before
157           activation), and shall be removed after use. Defaults to off.
158
159       key-slot=
160           Specifies the key slot to compare the passphrase or key against. If
161           the key slot does not match the given passphrase or key, but
162           another would, the setup of the device will fail regardless. This
163           option implies luks. See cryptsetup(8) for possible values. The
164           default is to try all key slots in sequential order.
165
166       keyfile-timeout=
167           Specifies the timeout for the device on which the key file resides
168           and falls back to a password if it could not be mounted. See
169           systemd-cryptsetup-generator(8) for key files on external devices.
170
171       luks
172           Force LUKS mode. When this mode is used, the following options are
173           ignored since they are provided by the LUKS header on the device:
174           cipher=, hash=, size=.
175
176       bitlk
177           Decrypt BitLocker drive. Encryption parameters are deduced by
178           cryptsetup from BitLocker header.
179
180       _netdev
181           Marks this cryptsetup device as requiring network. It will be
182           started after the network is available, similarly to
183           systemd.mount(5) units marked with _netdev. The service unit to set
184           up this device will be ordered between remote-fs-pre.target and
185           remote-cryptsetup.target, instead of cryptsetup-pre.target and
186           cryptsetup.target.
187
188           Hint: if this device is used for a mount point that is specified in
189           fstab(5), the _netdev option should also be used for the mount
190           point. Otherwise, a dependency loop might be created where the
191           mount point will be pulled in by local-fs.target, while the service
192           to configure the network is usually only started after the local
193           file system has been mounted.
194
195       noauto
196           This device will not be added to cryptsetup.target. This means that
197           it will not be automatically unlocked on boot, unless something
198           else pulls it in. In particular, if the device is used for a mount
199           point, it'll be unlocked automatically during boot, unless the
200           mount point itself is also disabled with noauto.
201
202       nofail
203           This device will not be a hard dependency of cryptsetup.target.
204           It'll still be pulled in and started, but the system will not wait
205           for the device to show up and be unlocked, and boot will not fail
206           if this is unsuccessful. Note that other units that depend on the
207           unlocked device may still fail. In particular, if the device is
208           used for a mount point, the mount point itself also needs to have
209           the nofail option, or the boot will fail if the device is not
210           unlocked successfully.
211
212       offset=
213           Start offset in the backend device, in 512-byte sectors. This
214           option is only relevant for plain devices.
215
216       plain
217           Force plain encryption mode.
218
219       read-only, readonly
220           Set up the encrypted block device in read-only mode.
221
222       same-cpu-crypt
223           Perform encryption using the same CPU that IO was submitted on. The
224           default is to use an unbound workqueue so that encryption work is
225           automatically balanced between available CPUs.
226
227           This requires kernel 4.0 or newer.
228
229       submit-from-crypt-cpus
230           Disable offloading writes to a separate thread after encryption.
231           There are some situations where offloading write requests from the
232           encryption threads to a dedicated thread degrades performance
233           significantly. The default is to offload write requests to a
234           dedicated thread because it benefits the CFQ scheduler to have
235           writes submitted using the same context.
236
237           This requires kernel 4.0 or newer.
238
239       no-read-workqueue
240           Bypass dm-crypt internal workqueue and process read requests
241           synchronously. The default is to queue these requests and process
242           them asynchronously.
243
244           This requires kernel 5.9 or newer.
245
246       no-write-workqueue
247           Bypass dm-crypt internal workqueue and process write requests
248           synchronously. The default is to queue these requests and process
249           them asynchronously.
250
251           This requires kernel 5.9 or newer.
252
253       skip=
254           How many 512-byte sectors of the encrypted data to skip at the
255           beginning. This is different from the offset= option with respect
256           to the sector numbers used in initialization vector (IV)
257           calculation. Using offset= will shift the IV calculation by the
258           same negative amount. Hence, if offset=n is given, sector n will
259           get a sector number of 0 for the IV calculation. Using skip= causes
260           sector n to also be the first sector of the mapped device, but with
261           its number for IV generation being n.
262
263           This option is only relevant for plain devices.
264
265       size=
266           Specifies the key size in bits. See cryptsetup(8) for possible
267           values and the default value of this option.
268
269       sector-size=
270           Specifies the sector size in bytes. See cryptsetup(8) for possible
271           values and the default value of this option.
272
273       swap
274           The encrypted block device will be used as a swap device, and will
275           be formatted accordingly after setting up the encrypted block
276           device, with mkswap(8). This option implies plain.
277
278           WARNING: Using the swap option will destroy the contents of the
279           named partition during every boot, so make sure the underlying
280           block device is specified correctly.
281
282       tcrypt
283           Use TrueCrypt encryption mode. When this mode is used, the
284           following options are ignored since they are provided by the
285           TrueCrypt header on the device or do not apply: cipher=, hash=,
286           keyfile-offset=, keyfile-size=, size=.
287
288           When this mode is used, the passphrase is read from the key file
289           given in the third field. Only the first line of this file is read,
290           excluding the new line character.
291
292           Note that the TrueCrypt format uses both passphrase and key files
293           to derive a password for the volume. Therefore, the passphrase and
294           all key files need to be provided. Use tcrypt-keyfile= to provide
295           the absolute path to all key files. When using an empty passphrase
296           in combination with one or more key files, use "/dev/null" as the
297           password file in the third field.
298
299       tcrypt-hidden
300           Use the hidden TrueCrypt volume. This option implies tcrypt.
301
302           This will map the hidden volume that is inside of the volume
303           provided in the second field. Please note that there is no
304           protection for the hidden volume if the outer volume is mounted
305           instead. See cryptsetup(8) for more information on this limitation.
306
307       tcrypt-keyfile=
308           Specifies the absolute path to a key file to use for a TrueCrypt
309           volume. This implies tcrypt and can be used more than once to
310           provide several key files.
311
312           See the entry for tcrypt on the behavior of the passphrase and key
313           files when using TrueCrypt encryption mode.
314
315       tcrypt-system
316           Use TrueCrypt in system encryption mode. This option implies
317           tcrypt.
318
319       tcrypt-veracrypt
320           Check for a VeraCrypt volume. VeraCrypt is a fork of TrueCrypt that
321           is mostly compatible, but uses different, stronger key derivation
322           algorithms that cannot be detected without this flag. Enabling this
323           option could substantially slow down unlocking, because VeraCrypt's
324           key derivation takes much longer than TrueCrypt's. This option
325           implies tcrypt.
326
327       timeout=
328           Specifies the timeout for querying for a password. If no unit is
329           specified, seconds is used. Supported units are s, ms, us, min, h,
330           d. A timeout of 0 waits indefinitely (which is the default).
331
332       tmp=
333           The encrypted block device will be prepared for using it as /tmp/;
334           it will be formatted using mkfs(8). Takes a file system type as
335           argument, such as "ext4", "xfs" or "btrfs". If no argument is
336           specified defaults to "ext4". This option implies plain.
337
338           WARNING: Using the tmp option will destroy the contents of the
339           named partition during every boot, so make sure the underlying
340           block device is specified correctly.
341
342       tries=
343           Specifies the maximum number of times the user is queried for a
344           password. The default is 3. If set to 0, the user is queried for a
345           password indefinitely.
346
347       headless=
348           Takes a boolean argument, defaults to false. If true, never query
349           interactively for the password/PIN. Useful for headless systems.
350
351       verify
352           If the encryption password is read from console, it has to be
353           entered twice to prevent typos.
354
355       password-echo=yes|no|masked
356           Controls whether to echo passwords or security token PINs that are
357           read from console. Takes a boolean or the special string "masked".
358           The default is password-echo=masked.
359
360           If enabled, the typed characters are echoed literally. If disabled,
361           the typed characters are not echoed in any form, the user will not
362           get feedback on their input. If set to "masked", an asterisk ("*")
363           is echoed for each character typed. Regardless of which mode is
364           chosen, if the user hits the tabulator key ("↹") at any time, or
365           the backspace key ("⌫") before any other data has been entered,
366           then echo is turned off.
367
368       pkcs11-uri=
369           Takes either the special value "auto" or an RFC7512 PKCS#11 URI[1]
370           pointing to a private RSA key which is used to decrypt the
371           encrypted key specified in the third column of the line. This is
372           useful for unlocking encrypted volumes through PKCS#11 compatible
373           security tokens or smartcards. See below for an example how to set
374           up this mechanism for unlocking a LUKS2 volume with a YubiKey
375           security token.
376
377           If specified as "auto" the volume must be of type LUKS2 and must
378           carry PKCS#11 security token metadata in its LUKS2 JSON token
379           section. In this mode the URI and the encrypted key are
380           automatically read from the LUKS2 JSON token header. Use systemd-
381           cryptenroll(1) as simple tool for enrolling PKCS#11 security tokens
382           or smartcards in a way compatible with "auto". In this mode the
383           third column of the line should remain empty (that is, specified as
384           "-").
385
386           The specified URI can refer directly to a private RSA key stored on
387           a token or alternatively just to a slot or token, in which case a
388           search for a suitable private RSA key will be performed. In this
389           case if multiple suitable objects are found the token is refused.
390           The encrypted key configured in the third column of the line is
391           passed as is (i.e. in binary form, unprocessed) to RSA decryption.
392           The resulting decrypted key is then Base64 encoded before it is
393           used to unlock the LUKS volume.
394
395           Use systemd-cryptenroll --pkcs11-token-uri=list to list all
396           suitable PKCS#11 security tokens currently plugged in, along with
397           their URIs.
398
399           Note that many newer security tokens that may be used as PKCS#11
400           security token typically also implement the newer and simpler FIDO2
401           standard. Consider using fido2-device= (described below) to enroll
402           it via FIDO2 instead. Note that a security token enrolled via
403           PKCS#11 cannot be used to unlock the volume via FIDO2, unless also
404           enrolled via FIDO2, and vice versa.
405
406       fido2-device=
407           Takes either the special value "auto" or the path to a "hidraw"
408           device node (e.g.  /dev/hidraw1) referring to a FIDO2 security
409           token that implements the "hmac-secret" extension (most current
410           hardware security tokens do). See below for an example how to set
411           up this mechanism for unlocking an encrypted volume with a FIDO2
412           security token.
413
414           If specified as "auto" the FIDO2 token device is automatically
415           discovered, as it is plugged in.
416
417           FIDO2 volume unlocking requires a client ID hash (CID) to be
418           configured via fido2-cid= (see below) and a key to pass to the
419           security token's HMAC functionality (configured in the line's third
420           column) to operate. If not configured and the volume is of type
421           LUKS2, the CID and the key are read from LUKS2 JSON token metadata
422           instead. Use systemd-cryptenroll(1) as simple tool for enrolling
423           FIDO2 security tokens, compatible with this automatic mode, which
424           is only available for LUKS2 volumes.
425
426           Use systemd-cryptenroll --fido2-device=list to list all suitable
427           FIDO2 security tokens currently plugged in, along with their device
428           nodes.
429
430           This option implements the following mechanism: the configured key
431           is hashed via they HMAC keyed hash function the FIDO2 device
432           implements, keyed by a secret key embedded on the device. The
433           resulting hash value is Base64 encoded and used to unlock the LUKS2
434           volume. As it should not be possible to extract the secret from the
435           hardware token, it should not be possible to retrieve the hashed
436           key given the configured key — without possessing the hardware
437           token.
438
439           Note that many security tokens that implement FIDO2 also implement
440           PKCS#11, suitable for unlocking volumes via the pkcs11-uri= option
441           described above. Typically the newer, simpler FIDO2 standard is
442           preferable.
443
444       fido2-cid=
445           Takes a Base64 encoded FIDO2 client ID to use for the FIDO2 unlock
446           operation. If specified, but fido2-device= is not,
447           fido2-device=auto is implied. If fido2-device= is used but
448           fido2-cid= is not, the volume must be of LUKS2 type, and the CID is
449           read from the LUKS2 JSON token header. Use systemd-cryptenroll(1)
450           for enrolling a FIDO2 token in the LUKS2 header compatible with
451           this automatic mode.
452
453       fido2-rp=
454           Takes a string, configuring the FIDO2 Relying Party (rp) for the
455           FIDO2 unlock operation. If not specified "io.systemd.cryptsetup" is
456           used, except if the LUKS2 JSON token header contains a different
457           value. It should normally not be necessary to override this.
458
459       tpm2-device=
460           Takes either the special value "auto" or the path to a device node
461           (e.g.  /dev/tpmrm0) referring to a TPM2 security chip. See below
462           for an example how to set up this mechanism for unlocking an
463           encrypted volume with a TPM2 chip.
464
465           Use tpm2-pcrs= (see below) to configure the set of TPM2 PCRs to
466           bind the volume unlocking to. Use systemd-cryptenroll(1) as simple
467           tool for enrolling TPM2 security chips in LUKS2 volumes.
468
469           If specified as "auto" the TPM2 device is automatically discovered.
470           Use systemd-cryptenroll --tpm2-device=list to list all suitable
471           TPM2 devices currently available, along with their device nodes.
472
473           This option implements the following mechanism: when enrolling a
474           TPM2 device via systemd-cryptenroll on a LUKS2 volume, a randomized
475           key unlocking the volume is generated on the host and loaded into
476           the TPM2 chip where it is encrypted with an asymmetric "primary"
477           key pair derived from the TPM2's internal "seed" key. Neither the
478           seed key nor the primary key are permitted to ever leave the TPM2
479           chip — however, the now encrypted randomized key may. It is saved
480           in the LUKS2 volume JSON token header. When unlocking the encrypted
481           volume, the primary key pair is generated on the TPM2 chip again
482           (which works as long as the chip's seed key is correctly maintained
483           by the TPM2 chip), which is then used to decrypt (on the TPM2 chip)
484           the encrypted key from the LUKS2 volume JSON token header saved
485           there during enrollment. The resulting decrypted key is then used
486           to unlock the volume. When the randomized key is encrypted the
487           current values of the selected PCRs (see below) are included in the
488           operation, so that different PCR state results in different
489           encrypted keys and the decrypted key can only be recovered if the
490           same PCR state is reproduced.
491
492       tpm2-pcrs=
493           Takes a "+" separated list of numeric TPM2 PCR (i.e. "Platform
494           Configuration Register") indexes to bind the TPM2 volume unlocking
495           to. This option is only useful when TPM2 enrollment metadata is not
496           available in the LUKS2 JSON token header already, the way
497           systemd-cryptenroll writes it there. If not used (and no metadata
498           in the LUKS2 JSON token header defines it), defaults to a list of a
499           single entry: PCR 7. Assign an empty string to encode a policy that
500           binds the key to no PCRs, making the key accessible to local
501           programs regardless of the current PCR state.
502
503       token-timeout=
504           Specifies how long to wait at most for configured security devices
505           (i.e. FIDO2, PKCS#11, TPM2) to show up. Takes a time value in
506           seconds (but other time units may be specified too, see
507           systemd.time(7) for supported formats). Defaults to 30s. Once the
508           specified timeout elapsed authentication via password is attempted.
509           Note that this timeout applies to waiting for the security device
510           to show up — it does not apply to the PIN prompt for the device
511           (should one be needed) or similar. Pass 0 to turn off the time-out
512           and wait forever.
513
514       try-empty-password=
515           Takes a boolean argument. If enabled, right before asking the user
516           for a password it is first attempted to unlock the volume with an
517           empty password. This is useful for systems that are initialized
518           with an encrypted volume with only an empty password set, which
519           shall be replaced with a suitable password during first boot, but
520           after activation.
521
522       x-systemd.device-timeout=
523           Specifies how long systemd should wait for a block device to show
524           up before giving up on the entry. The argument is a time in seconds
525           or explicitly specified units of "s", "min", "h", "ms".
526
527       x-initrd.attach
528           Setup this encrypted block device in the initramfs, similarly to
529           systemd.mount(5) units marked with x-initrd.mount.
530
531           Although it's not necessary to mark the mount entry for the root
532           file system with x-initrd.mount, x-initrd.attach is still
533           recommended with the encrypted block device containing the root
534           file system as otherwise systemd will attempt to detach the device
535           during the regular system shutdown while it's still in use. With
536           this option the device will still be detached but later after the
537           root file system is unmounted.
538
539           All other encrypted block devices that contain file systems mounted
540           in the initramfs should use this option.
541
542       At early boot and when the system manager configuration is reloaded,
543       this file is translated into native systemd units by systemd-
544       cryptsetup-generator(8).
545

AF_UNIX KEY FILES

547       If the key file path (as specified in the third column of /etc/crypttab
548       entries, see above) refers to an AF_UNIX stream socket in the file
549       system, the key is acquired by connecting to the socket and reading the
550       key from the connection. The connection is made from an AF_UNIX socket
551       name in the abstract namespace, see unix(7) for details. The source
552       socket name is chosen according the following format:
553
554           NUL RANDOM "/cryptsetup/" VOLUME
555
556       In other words: a NUL byte (as required for abstract namespace
557       sockets), followed by a random string (consisting of alphanumeric
558       characters only), followed by the literal string "/cryptsetup/",
559       followed by the name of the volume to acquire they key for. Example
560       (for a volume "myvol"):
561
562       Example 1.
563
564           \0d7067f78d9827418/cryptsetup/myvol
565
566       Services listening on the AF_UNIX stream socket may query the source
567       socket name with getpeername(2), and use it to determine which key to
568       send, allowing a single listening socket to serve keys for a multitude
569       of volumes. If the PKCS#11 logic is used (see above) the socket source
570       name is picked in identical fashion, except that the literal string
571       "/cryptsetup-pkcs11/" is used (similar for FIDO2: "/cryptsetup-fido2/"
572       and TPM2: "/cryptsetup-tpm2/"). This is done so that services providing
573       key material know that not a secret key is requested but an encrypted
574       key that will be decrypted via the PKCS#11/FIDO2/TPM2 logic to acquire
575       the final secret key.
576

EXAMPLES

578       Example 2. /etc/crypttab example
579
580       Set up four encrypted block devices. One using LUKS for normal storage,
581       another one for usage as a swap device and two TrueCrypt volumes. For
582       the fourth device, the option string is interpreted as two options
583       "cipher=xchacha12,aes-adiantum-plain64", "keyfile-timeout=10s".
584
585           luks       UUID=2505567a-9e27-4efe-a4d5-15ad146c258b
586           swap       /dev/sda7       /dev/urandom       swap
587           truecrypt  /dev/sda2       /etc/container_password  tcrypt
588           hidden     /mnt/tc_hidden  /dev/null    tcrypt-hidden,tcrypt-keyfile=/etc/keyfile
589           external   /dev/sda3       keyfile:LABEL=keydev keyfile-timeout=10s,cipher=xchacha12\,aes-adiantum-plain64
590
591       Example 3. Yubikey-based PKCS#11 Volume Unlocking Example
592
593       The PKCS#11 logic allows hooking up any compatible security token that
594       is capable of storing RSA decryption keys for unlocking an encrypted
595       volume. Here's an example how to set up a Yubikey security token for
596       this purpose on a LUKS2 volume, using ykmap(1) from the yubikey-manager
597       project to initialize the token and systemd-cryptenroll(1) to add it in
598       the LUKS2 volume:
599
600           # SPDX-License-Identifier: CC0-1.0
601
602           # Destroy any old key on the Yubikey (careful!)
603           ykman piv reset
604
605           # Generate a new private/public key pair on the device, store the public key in
606           # 'pubkey.pem'.
607           ykman piv generate-key -a RSA2048 9d pubkey.pem
608
609           # Create a self-signed certificate from this public key, and store it on the
610           # device. The "subject" should be an arbitrary user-chosen string to identify
611           # the token with.
612           ykman piv generate-certificate --subject "Knobelei" 9d pubkey.pem
613
614           # We don't need the public key anymore, let's remove it. Since it is not
615           # security sensitive we just do a regular "rm" here.
616           rm pubkey.pem
617
618           # Enroll the freshly initialized security token in the LUKS2 volume. Replace
619           # /dev/sdXn by the partition to use (e.g. /dev/sda1).
620           sudo systemd-cryptenroll --pkcs11-token-uri=auto /dev/sdXn
621
622           # Test: Let's run systemd-cryptsetup to test if this all worked.
623           sudo /usr/lib/systemd/systemd-cryptsetup attach mytest /dev/sdXn - pkcs11-uri=auto
624
625           # If that worked, let's now add the same line persistently to /etc/crypttab,
626           # for the future.
627           sudo bash -c 'echo "mytest /dev/sdXn - pkcs11-uri=auto" >> /etc/crypttab'
628
629       A few notes on the above:
630
631       •   We use RSA2048, which is the longest key size current Yubikeys
632           support
633
634       •   We use Yubikey key slot 9d, since that's apparently the keyslot to
635           use for decryption purposes, see documentation[2].
636
637       Example 4. FIDO2 Volume Unlocking Example
638
639       The FIDO2 logic allows using any compatible FIDO2 security token that
640       implements the "hmac-secret" extension for unlocking an encrypted
641       volume. Here's an example how to set up a FIDO2 security token for this
642       purpose for a LUKS2 volume, using systemd-cryptenroll(1):
643
644           # SPDX-License-Identifier: CC0-1.0
645
646           # Enroll the security token in the LUKS2 volume. Replace /dev/sdXn by the
647           # partition to use (e.g. /dev/sda1).
648           sudo systemd-cryptenroll --fido2-device=auto /dev/sdXn
649
650           # Test: Let's run systemd-cryptsetup to test if this worked.
651           sudo /usr/lib/systemd/systemd-cryptsetup attach mytest /dev/sdXn - fido2-device=auto
652
653           # If that worked, let's now add the same line persistently to /etc/crypttab,
654           # for the future.
655           sudo bash -c 'echo "mytest /dev/sdXn - fido2-device=auto" >> /etc/crypttab'
656
657       Example 5. TPM2 Volume Unlocking Example
658
659       The TPM2 logic allows using any TPM2 chip supported by the Linux kernel
660       for unlocking an encrypted volume. Here's an example how to set up a
661       TPM2 chip for this purpose for a LUKS2 volume, using systemd-
662       cryptenroll(1):
663
664           # SPDX-License-Identifier: CC0-1.0
665
666           # Enroll the TPM2 security chip in the LUKS2 volume, and bind it to PCR 7
667           # only. Replace /dev/sdXn by the partition to use (e.g. /dev/sda1).
668           sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=7 /dev/sdXn
669
670           # Test: Let's run systemd-cryptsetup to test if this worked.
671           sudo /usr/lib/systemd/systemd-cryptsetup attach mytest /dev/sdXn - tpm2-device=auto
672
673           # If that worked, let's now add the same line persistently to /etc/crypttab,
674           # for the future.
675           sudo bash -c 'echo "mytest /dev/sdXn - tpm2-device=auto" >> /etc/crypttab'
676

SEE ALSO

678       systemd(1), systemd-cryptsetup@.service(8), systemd-cryptsetup-
679       generator(8), systemd-cryptenroll(1), fstab(5), cryptsetup(8),
680       mkswap(8), mke2fs(8)
681

NOTES

683        1. RFC7512 PKCS#11 URI
684           https://tools.ietf.org/html/rfc7512
685
686        2. see documentation
687           https://developers.yubico.com/PIV/Introduction/Certificate_slots.html
688
689
690
691systemd 250                                                        CRYPTTAB(5)
Impressum