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