1CRYPTTAB(5) crypttab CRYPTTAB(5)
2
3
4
6 crypttab - Configuration for encrypted block devices
7
9 /etc/crypttab
10
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
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 passphrases.
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. Similarly, 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 key generated randomly during enrollment 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. Similarly, the key may be acquired via a TPM2 security chip. In
97 this case a (during enrollment) randomly generated key — encrypted
98 by an asymmetric key derived from the TPM2 chip's seed key — is
99 stored on disk/removable media, acquired via AF_UNIX, or stored in
100 the LUKS2 JSON token metadata header. Use the tpm2-device= option
101 described 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
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 or the device used as the key file, and falls back to a password if
169 it could not be accessed. See systemd-cryptsetup-generator(8) for
170 key files on external devices.
171
172 luks
173 Force LUKS mode. When this mode is used, the following options are
174 ignored since they are provided by the LUKS header on the device:
175 cipher=, hash=, size=.
176
177 bitlk
178 Decrypt BitLocker drive. Encryption parameters are deduced by
179 cryptsetup from BitLocker header.
180
181 _netdev
182 Marks this cryptsetup device as requiring network. It will be
183 started after the network is available, similarly to
184 systemd.mount(5) units marked with _netdev. The service unit to set
185 up this device will be ordered between remote-fs-pre.target and
186 remote-cryptsetup.target, instead of cryptsetup-pre.target and
187 cryptsetup.target.
188
189 Hint: if this device is used for a mount point that is specified in
190 fstab(5), the _netdev option should also be used for the mount
191 point. Otherwise, a dependency loop might be created where the
192 mount point will be pulled in by local-fs.target, while the service
193 to configure the network is usually only started after the local
194 file system has been mounted.
195
196 noauto
197 This device will not be added to cryptsetup.target. This means that
198 it will not be automatically unlocked on boot, unless something
199 else pulls it in. In particular, if the device is used for a mount
200 point, it'll be unlocked automatically during boot, unless the
201 mount point itself is also disabled with noauto.
202
203 nofail
204 This device will not be a hard dependency of cryptsetup.target.
205 It'll still be pulled in and started, but the system will not wait
206 for the device to show up and be unlocked, and boot will not fail
207 if this is unsuccessful. Note that other units that depend on the
208 unlocked device may still fail. In particular, if the device is
209 used for a mount point, the mount point itself also needs to have
210 the nofail option, or the boot will fail if the device is not
211 unlocked successfully.
212
213 offset=
214 Start offset in the backend device, in 512-byte sectors. This
215 option is only relevant for plain devices.
216
217 plain
218 Force plain encryption mode.
219
220 read-only, readonly
221 Set up the encrypted block device in read-only mode.
222
223 same-cpu-crypt
224 Perform encryption using the same CPU that IO was submitted on. The
225 default is to use an unbound workqueue so that encryption work is
226 automatically balanced between available CPUs.
227
228 This requires kernel 4.0 or newer.
229
230 submit-from-crypt-cpus
231 Disable offloading writes to a separate thread after encryption.
232 There are some situations where offloading write requests from the
233 encryption threads to a dedicated thread degrades performance
234 significantly. The default is to offload write requests to a
235 dedicated thread because it benefits the CFQ scheduler to have
236 writes submitted using the same context.
237
238 This requires kernel 4.0 or newer.
239
240 no-read-workqueue
241 Bypass dm-crypt internal workqueue and process read requests
242 synchronously. The default is to queue these requests and process
243 them asynchronously.
244
245 This requires kernel 5.9 or newer.
246
247 no-write-workqueue
248 Bypass dm-crypt internal workqueue and process write requests
249 synchronously. The default is to queue these requests and process
250 them asynchronously.
251
252 This requires kernel 5.9 or newer.
253
254 skip=
255 How many 512-byte sectors of the encrypted data to skip at the
256 beginning. This is different from the offset= option with respect
257 to the sector numbers used in initialization vector (IV)
258 calculation. Using offset= will shift the IV calculation by the
259 same negative amount. Hence, if offset=n is given, sector n will
260 get a sector number of 0 for the IV calculation. Using skip= causes
261 sector n to also be the first sector of the mapped device, but with
262 its number for IV generation being n.
263
264 This option is only relevant for plain devices.
265
266 size=
267 Specifies the key size in bits. See cryptsetup(8) for possible
268 values and the default value of this option.
269
270 sector-size=
271 Specifies the sector size in bytes. See cryptsetup(8) for possible
272 values and the default value of this option.
273
274 swap
275 The encrypted block device will be used as a swap device, and will
276 be formatted accordingly after setting up the encrypted block
277 device, with mkswap(8). This option implies plain.
278
279 WARNING: Using the swap option will destroy the contents of the
280 named partition during every boot, so make sure the underlying
281 block device is specified correctly.
282
283 tcrypt
284 Use TrueCrypt encryption mode. When this mode is used, the
285 following options are ignored since they are provided by the
286 TrueCrypt header on the device or do not apply: cipher=, hash=,
287 keyfile-offset=, keyfile-size=, size=.
288
289 When this mode is used, the passphrase is read from the key file
290 given in the third field. Only the first line of this file is read,
291 excluding the new line character.
292
293 Note that the TrueCrypt format uses both passphrase and key files
294 to derive a password for the volume. Therefore, the passphrase and
295 all key files need to be provided. Use tcrypt-keyfile= to provide
296 the absolute path to all key files. When using an empty passphrase
297 in combination with one or more key files, use "/dev/null" as the
298 password file in the third field.
299
300 tcrypt-hidden
301 Use the hidden TrueCrypt volume. This option implies tcrypt.
302
303 This will map the hidden volume that is inside of the volume
304 provided in the second field. Please note that there is no
305 protection for the hidden volume if the outer volume is mounted
306 instead. See cryptsetup(8) for more information on this limitation.
307
308 tcrypt-keyfile=
309 Specifies the absolute path to a key file to use for a TrueCrypt
310 volume. This implies tcrypt and can be used more than once to
311 provide several key files.
312
313 See the entry for tcrypt on the behavior of the passphrase and key
314 files when using TrueCrypt encryption mode.
315
316 tcrypt-system
317 Use TrueCrypt in system encryption mode. This option implies
318 tcrypt.
319
320 tcrypt-veracrypt
321 Check for a VeraCrypt volume. VeraCrypt is a fork of TrueCrypt that
322 is mostly compatible, but uses different, stronger key derivation
323 algorithms that cannot be detected without this flag. Enabling this
324 option could substantially slow down unlocking, because VeraCrypt's
325 key derivation takes much longer than TrueCrypt's. This option
326 implies tcrypt.
327
328 timeout=
329 Specifies the timeout for querying for a password. If no unit is
330 specified, seconds is used. Supported units are s, ms, us, min, h,
331 d. A timeout of 0 waits indefinitely (which is the default).
332
333 tmp=
334 The encrypted block device will be prepared for using it as /tmp/;
335 it will be formatted using mkfs(8). Takes a file system type as
336 argument, such as "ext4", "xfs" or "btrfs". If no argument is
337 specified defaults to "ext4". This option implies plain.
338
339 WARNING: Using the tmp option will destroy the contents of the
340 named partition during every boot, so make sure the underlying
341 block device is specified correctly.
342
343 tries=
344 Specifies the maximum number of times the user is queried for a
345 password. The default is 3. If set to 0, the user is queried for a
346 password indefinitely.
347
348 headless=
349 Takes a boolean argument, defaults to false. If true, never query
350 interactively for the password/PIN. Useful for headless systems.
351
352 verify
353 If the encryption password is read from console, it has to be
354 entered twice to prevent typos.
355
356 password-echo=yes|no|masked
357 Controls whether to echo passwords or security token PINs that are
358 read from console. Takes a boolean or the special string "masked".
359 The default is password-echo=masked.
360
361 If enabled, the typed characters are echoed literally. If disabled,
362 the typed characters are not echoed in any form, the user will not
363 get feedback on their input. If set to "masked", an asterisk ("*")
364 is echoed for each character typed. Regardless of which mode is
365 chosen, if the user hits the tabulator key ("↹") at any time, or
366 the backspace key ("⌫") before any other data has been entered,
367 then echo is turned off.
368
369 pkcs11-uri=
370 Takes either the special value "auto" or an RFC7512 PKCS#11 URI[1]
371 pointing to a private RSA key which is used to decrypt the
372 encrypted key specified in the third column of the line. This is
373 useful for unlocking encrypted volumes through PKCS#11 compatible
374 security tokens or smartcards. See below for an example how to set
375 up this mechanism for unlocking a LUKS2 volume with a YubiKey
376 security token.
377
378 If specified as "auto" the volume must be of type LUKS2 and must
379 carry PKCS#11 security token metadata in its LUKS2 JSON token
380 section. In this mode the URI and the encrypted key are
381 automatically read from the LUKS2 JSON token header. Use systemd-
382 cryptenroll(1) as simple tool for enrolling PKCS#11 security tokens
383 or smartcards in a way compatible with "auto". In this mode the
384 third column of the line should remain empty (that is, specified as
385 "-").
386
387 The specified URI can refer directly to a private RSA key stored on
388 a token or alternatively just to a slot or token, in which case a
389 search for a suitable private RSA key will be performed. In this
390 case if multiple suitable objects are found the token is refused.
391 The encrypted key configured in the third column of the line is
392 passed as is (i.e. in binary form, unprocessed) to RSA decryption.
393 The resulting decrypted key is then Base64 encoded before it is
394 used to unlock the LUKS volume.
395
396 Use systemd-cryptenroll --pkcs11-token-uri=list to list all
397 suitable PKCS#11 security tokens currently plugged in, along with
398 their URIs.
399
400 Note that many newer security tokens that may be used as PKCS#11
401 security token typically also implement the newer and simpler FIDO2
402 standard. Consider using fido2-device= (described below) to enroll
403 it via FIDO2 instead. Note that a security token enrolled via
404 PKCS#11 cannot be used to unlock the volume via FIDO2, unless also
405 enrolled via FIDO2, and vice versa.
406
407 fido2-device=
408 Takes either the special value "auto" or the path to a "hidraw"
409 device node (e.g. /dev/hidraw1) referring to a FIDO2 security
410 token that implements the "hmac-secret" extension (most current
411 hardware security tokens do). See below for an example how to set
412 up this mechanism for unlocking an encrypted volume with a FIDO2
413 security token.
414
415 If specified as "auto" the FIDO2 token device is automatically
416 discovered, as it is plugged in.
417
418 FIDO2 volume unlocking requires a client ID hash (CID) to be
419 configured via fido2-cid= (see below) and a key to pass to the
420 security token's HMAC functionality (configured in the line's third
421 column) to operate. If not configured and the volume is of type
422 LUKS2, the CID and the key are read from LUKS2 JSON token metadata
423 instead. Use systemd-cryptenroll(1) as simple tool for enrolling
424 FIDO2 security tokens, compatible with this automatic mode, which
425 is only available for LUKS2 volumes.
426
427 Use systemd-cryptenroll --fido2-device=list to list all suitable
428 FIDO2 security tokens currently plugged in, along with their device
429 nodes.
430
431 This option implements the following mechanism: the configured key
432 is hashed via they HMAC keyed hash function the FIDO2 device
433 implements, keyed by a secret key embedded on the device. The
434 resulting hash value is Base64 encoded and used to unlock the LUKS2
435 volume. As it should not be possible to extract the secret from the
436 hardware token, it should not be possible to retrieve the hashed
437 key given the configured key — without possessing the hardware
438 token.
439
440 Note that many security tokens that implement FIDO2 also implement
441 PKCS#11, suitable for unlocking volumes via the pkcs11-uri= option
442 described above. Typically the newer, simpler FIDO2 standard is
443 preferable.
444
445 fido2-cid=
446 Takes a Base64 encoded FIDO2 client ID to use for the FIDO2 unlock
447 operation. If specified, but fido2-device= is not,
448 fido2-device=auto is implied. If fido2-device= is used but
449 fido2-cid= is not, the volume must be of LUKS2 type, and the CID is
450 read from the LUKS2 JSON token header. Use systemd-cryptenroll(1)
451 for enrolling a FIDO2 token in the LUKS2 header compatible with
452 this automatic mode.
453
454 fido2-rp=
455 Takes a string, configuring the FIDO2 Relying Party (rp) for the
456 FIDO2 unlock operation. If not specified "io.systemd.cryptsetup" is
457 used, except if the LUKS2 JSON token header contains a different
458 value. It should normally not be necessary to override this.
459
460 tpm2-device=
461 Takes either the special value "auto" or the path to a device node
462 (e.g. /dev/tpmrm0) referring to a TPM2 security chip. See below
463 for an example how to set up this mechanism for unlocking an
464 encrypted volume with a TPM2 chip.
465
466 Use tpm2-pcrs= (see below) to configure the set of TPM2 PCRs to
467 bind the volume unlocking to. Use systemd-cryptenroll(1) as simple
468 tool for enrolling TPM2 security chips in LUKS2 volumes.
469
470 If specified as "auto" the TPM2 device is automatically discovered.
471 Use systemd-cryptenroll --tpm2-device=list to list all suitable
472 TPM2 devices currently available, along with their device nodes.
473
474 This option implements the following mechanism: when enrolling a
475 TPM2 device via systemd-cryptenroll on a LUKS2 volume, a randomized
476 key unlocking the volume is generated on the host and loaded into
477 the TPM2 chip where it is encrypted with an asymmetric "primary"
478 key pair derived from the TPM2's internal "seed" key. Neither the
479 seed key nor the primary key are permitted to ever leave the TPM2
480 chip — however, the now encrypted randomized key may. It is saved
481 in the LUKS2 volume JSON token header. When unlocking the encrypted
482 volume, the primary key pair is generated on the TPM2 chip again
483 (which works as long as the chip's seed key is correctly maintained
484 by the TPM2 chip), which is then used to decrypt (on the TPM2 chip)
485 the encrypted key from the LUKS2 volume JSON token header saved
486 there during enrollment. The resulting decrypted key is then used
487 to unlock the volume. When the randomized key is encrypted the
488 current values of the selected PCRs (see below) are included in the
489 operation, so that different PCR state results in different
490 encrypted keys and the decrypted key can only be recovered if the
491 same PCR state is reproduced.
492
493 tpm2-pcrs=
494 Takes a "+" separated list of numeric TPM2 PCR (i.e. "Platform
495 Configuration Register") indexes to bind the TPM2 volume unlocking
496 to. This option is only useful when TPM2 enrollment metadata is not
497 available in the LUKS2 JSON token header already, the way
498 systemd-cryptenroll writes it there. If not used (and no metadata
499 in the LUKS2 JSON token header defines it), defaults to a list of a
500 single entry: PCR 7. Assign an empty string to encode a policy that
501 binds the key to no PCRs, making the key accessible to local
502 programs regardless of the current PCR state.
503
504 tpm2-pin=
505 Takes a boolean argument, defaults to "false". Controls whether
506 TPM2 volume unlocking is bound to a PIN in addition to PCRs.
507 Similarly, this option is only useful when TPM2 enrollment metadata
508 is not available.
509
510 tpm2-signature=
511 Takes an absolute path to a TPM2 PCR JSON signature file, as
512 produced by the systemd-measure(1) tool. This permits locking LUKS2
513 volumes to any PCR values for which a valid signature matching a
514 public key specified at key enrollment time can be provided. See
515 systemd-cryptenroll(1) for details on enrolling TPM2 PCR public
516 keys. If this option is not specified but it is attempted to unlock
517 a LUKS2 volume with a signed TPM2 PCR enrollment a suitable
518 signature file tpm2-pcr-signature.json is searched for in
519 /etc/systemd/, /run/systemd/, /usr/lib/systemd/ (in this order).
520
521 tpm2-measure-pcr=
522 Controls whether to measure the volume key of the encrypted volume
523 to a TPM2 PCR. If set to "no" (which is the default) no PCR
524 extension is done. If set to "yes" the volume key is measured into
525 PCR 15. If set to a decimal integer in the range 0...23 the volume
526 key is measured into the specified PCR. The volume key is measured
527 along with the activated volume name and its UUID. This
528 functionality is particularly useful for the encrypted volume
529 backing the root file system, as it then allows later TPM objects
530 to be securely bound to the root file system and hence the specific
531 installation.
532
533 tpm2-measure-bank=
534 Selects one or more TPM2 PCR banks to measure the volume key into,
535 as configured with tpm2-measure-pcr= above. Multiple banks may be
536 specified, separated by a colon character. If not specified
537 automatically determines available and used banks. Expects a
538 message digest name (e.g. "sha1", "sha256", ...) as argument, to
539 identify the bank.
540
541 token-timeout=
542 Specifies how long to wait at most for configured security devices
543 (i.e. FIDO2, PKCS#11, TPM2) to show up. Takes a time value in
544 seconds (but other time units may be specified too, see
545 systemd.time(7) for supported formats). Defaults to 30s. Once the
546 specified timeout elapsed authentication via password is attempted.
547 Note that this timeout applies to waiting for the security device
548 to show up — it does not apply to the PIN prompt for the device
549 (should one be needed) or similar. Pass 0 to turn off the time-out
550 and wait forever.
551
552 try-empty-password=
553 Takes a boolean argument. If enabled, right before asking the user
554 for a password it is first attempted to unlock the volume with an
555 empty password. This is useful for systems that are initialized
556 with an encrypted volume with only an empty password set, which
557 shall be replaced with a suitable password during first boot, but
558 after activation.
559
560 x-systemd.device-timeout=
561 Specifies how long systemd should wait for a block device to show
562 up before giving up on the entry. The argument is a time in seconds
563 or explicitly specified units of "s", "min", "h", "ms".
564
565 x-initrd.attach
566 Setup this encrypted block device in the initrd, similarly to
567 systemd.mount(5) units marked with x-initrd.mount.
568
569 Although it's not necessary to mark the mount entry for the root
570 file system with x-initrd.mount, x-initrd.attach is still
571 recommended with the encrypted block device containing the root
572 file system as otherwise systemd will attempt to detach the device
573 during the regular system shutdown while it's still in use. With
574 this option the device will still be detached but later after the
575 root file system is unmounted.
576
577 All other encrypted block devices that contain file systems mounted
578 in the initrd should use this option.
579
580 At early boot and when the system manager configuration is reloaded,
581 this file is translated into native systemd units by systemd-
582 cryptsetup-generator(8).
583
585 If the key file path (as specified in the third column of /etc/crypttab
586 entries, see above) refers to an AF_UNIX stream socket in the file
587 system, the key is acquired by connecting to the socket and reading the
588 key from the connection. The connection is made from an AF_UNIX socket
589 name in the abstract namespace, see unix(7) for details. The source
590 socket name is chosen according the following format:
591
592 NUL RANDOM /cryptsetup/ VOLUME
593
594 In other words: a NUL byte (as required for abstract namespace
595 sockets), followed by a random string (consisting of alphanumeric
596 characters only), followed by the literal string "/cryptsetup/",
597 followed by the name of the volume to acquire they key for. For
598 example, for the volume "myvol":
599
600 \0d7067f78d9827418/cryptsetup/myvol
601
602 Services listening on the AF_UNIX stream socket may query the source
603 socket name with getpeername(2), and use this to determine which key to
604 send, allowing a single listening socket to serve keys for multiple
605 volumes. If the PKCS#11 logic is used (see above), the socket source
606 name is picked in similar fashion, except that the literal string
607 "/cryptsetup-pkcs11/" is used. And similarly for FIDO2
608 ("/cryptsetup-fido2/") and TPM2 ("/cryptsetup-tpm2/"). A different path
609 component is used so that services providing key material know that the
610 secret key was not requested directly, but instead an encrypted key
611 that will be decrypted via the PKCS#11/FIDO2/TPM2 logic to acquire the
612 final secret key.
613
615 Example 1. /etc/crypttab example
616
617 Set up four encrypted block devices. One using LUKS for normal storage,
618 another one for usage as a swap device and two TrueCrypt volumes. For
619 the fourth device, the option string is interpreted as two options
620 "cipher=xchacha12,aes-adiantum-plain64", "keyfile-timeout=10s".
621
622 luks UUID=2505567a-9e27-4efe-a4d5-15ad146c258b
623 swap /dev/sda7 /dev/urandom swap
624 truecrypt /dev/sda2 /etc/container_password tcrypt
625 hidden /mnt/tc_hidden /dev/null tcrypt-hidden,tcrypt-keyfile=/etc/keyfile
626 external /dev/sda3 keyfile:LABEL=keydev keyfile-timeout=10s,cipher=xchacha12\,aes-adiantum-plain64
627
628 Example 2. Yubikey-based PKCS#11 Volume Unlocking Example
629
630 The PKCS#11 logic allows hooking up any compatible security token that
631 is capable of storing RSA decryption keys for unlocking an encrypted
632 volume. Here's an example how to set up a Yubikey security token for
633 this purpose on a LUKS2 volume, using ykmap(1) from the yubikey-manager
634 project to initialize the token and systemd-cryptenroll(1) to add it in
635 the LUKS2 volume:
636
637 # SPDX-License-Identifier: MIT-0
638
639 # Destroy any old key on the Yubikey (careful!)
640 ykman piv reset
641
642 # Generate a new private/public key pair on the device, store the public key in
643 # 'pubkey.pem'.
644 ykman piv generate-key -a RSA2048 9d pubkey.pem
645
646 # Create a self-signed certificate from this public key, and store it on the
647 # device. The "subject" should be an arbitrary user-chosen string to identify
648 # the token with.
649 ykman piv generate-certificate --subject "Knobelei" 9d pubkey.pem
650
651 # We don't need the public key anymore, let's remove it. Since it is not
652 # security sensitive we just do a regular "rm" here.
653 rm pubkey.pem
654
655 # Enroll the freshly initialized security token in the LUKS2 volume. Replace
656 # /dev/sdXn by the partition to use (e.g. /dev/sda1).
657 sudo systemd-cryptenroll --pkcs11-token-uri=auto /dev/sdXn
658
659 # Test: Let's run systemd-cryptsetup to test if this all worked.
660 sudo /usr/lib/systemd/systemd-cryptsetup attach mytest /dev/sdXn - pkcs11-uri=auto
661
662 # If that worked, let's now add the same line persistently to /etc/crypttab,
663 # for the future.
664 sudo bash -c 'echo "mytest /dev/sdXn - pkcs11-uri=auto" >>/etc/crypttab'
665
666 A few notes on the above:
667
668 • We use RSA2048, which is the longest key size current Yubikeys
669 support
670
671 • We use Yubikey key slot 9d, since that's apparently the keyslot to
672 use for decryption purposes, see documentation[2].
673
674 Example 3. FIDO2 Volume Unlocking Example
675
676 The FIDO2 logic allows using any compatible FIDO2 security token that
677 implements the "hmac-secret" extension for unlocking an encrypted
678 volume. Here's an example how to set up a FIDO2 security token for this
679 purpose for a LUKS2 volume, using systemd-cryptenroll(1):
680
681 # SPDX-License-Identifier: MIT-0
682
683 # Enroll the security token in the LUKS2 volume. Replace /dev/sdXn by the
684 # partition to use (e.g. /dev/sda1).
685 sudo systemd-cryptenroll --fido2-device=auto /dev/sdXn
686
687 # Test: Let's run systemd-cryptsetup to test if this worked.
688 sudo /usr/lib/systemd/systemd-cryptsetup attach mytest /dev/sdXn - fido2-device=auto
689
690 # If that worked, let's now add the same line persistently to /etc/crypttab,
691 # for the future.
692 sudo bash -c 'echo "mytest /dev/sdXn - fido2-device=auto" >>/etc/crypttab'
693
694 Example 4. TPM2 Volume Unlocking Example
695
696 The TPM2 logic allows using any TPM2 chip supported by the Linux kernel
697 for unlocking an encrypted volume. Here's an example how to set up a
698 TPM2 chip for this purpose for a LUKS2 volume, using systemd-
699 cryptenroll(1):
700
701 # SPDX-License-Identifier: MIT-0
702
703 # Enroll the TPM2 security chip in the LUKS2 volume, and bind it to PCR 7
704 # only. Replace /dev/sdXn by the partition to use (e.g. /dev/sda1).
705 sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=7 /dev/sdXn
706
707 # Test: Let's run systemd-cryptsetup to test if this worked.
708 sudo /usr/lib/systemd/systemd-cryptsetup attach mytest /dev/sdXn - tpm2-device=auto
709
710 # If that worked, let's now add the same line persistently to /etc/crypttab,
711 # for the future.
712 sudo bash -c 'echo "mytest /dev/sdXn - tpm2-device=auto" >>/etc/crypttab'
713
715 systemd(1), systemd-cryptsetup@.service(8), systemd-cryptsetup-
716 generator(8), systemd-cryptenroll(1), fstab(5), cryptsetup(8),
717 mkswap(8), mke2fs(8)
718
720 1. RFC7512 PKCS#11 URI
721 https://tools.ietf.org/html/rfc7512
722
723 2. see documentation
724 https://developers.yubico.com/PIV/Introduction/Certificate_slots.html
725
726
727
728systemd 253 CRYPTTAB(5)