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       verify
348           If the encryption password is read from console, it has to be
349           entered twice to prevent typos.
350
351       pkcs11-uri=
352           Takes either the special value "auto" or an RFC7512 PKCS#11 URI[1]
353           pointing to a private RSA key which is used to decrypt the
354           encrypted key specified in the third column of the line. This is
355           useful for unlocking encrypted volumes through PKCS#11 compatible
356           security tokens or smartcards. See below for an example how to set
357           up this mechanism for unlocking a LUKS2 volume with a YubiKey
358           security token.
359
360           If specified as "auto" the volume must be of type LUKS2 and must
361           carry PKCS#11 security token metadata in its LUKS2 JSON token
362           section. In this mode the URI and the encrypted key are
363           automatically read from the LUKS2 JSON token header. Use systemd-
364           cryptenroll(1) as simple tool for enrolling PKCS#11 security tokens
365           or smartcards in a way compatible with "auto". In this mode the
366           third column of the line should remain empty (that is, specified as
367           "-").
368
369           The specified URI can refer directly to a private RSA key stored on
370           a token or alternatively just to a slot or token, in which case a
371           search for a suitable private RSA key will be performed. In this
372           case if multiple suitable objects are found the token is refused.
373           The encrypted key configured in the third column of the line is
374           passed as is (i.e. in binary form, unprocessed) to RSA decryption.
375           The resulting decrypted key is then Base64 encoded before it is
376           used to unlock the LUKS volume.
377
378           Use systemd-cryptenroll --pkcs11-token-uri=list to list all
379           suitable PKCS#11 security tokens currently plugged in, along with
380           their URIs.
381
382           Note that many newer security tokens that may be used as PKCS#11
383           security token typically also implement the newer and simpler FIDO2
384           standard. Consider using fido2-device= (described below) to enroll
385           it via FIDO2 instead. Note that a security token enrolled via
386           PKCS#11 cannot be used to unlock the volume via FIDO2, unless also
387           enrolled via FIDO2, and vice versa.
388
389       fido2-device=
390           Takes either the special value "auto" or the path to a "hidraw"
391           device node (e.g.  /dev/hidraw1) referring to a FIDO2 security
392           token that implements the "hmac-secret" extension (most current
393           hardware security tokens do). See below for an example how to set
394           up this mechanism for unlocking an encrypted volume with a FIDO2
395           security token.
396
397           If specified as "auto" the FIDO2 token device is automatically
398           discovered, as it is plugged in.
399
400           FIDO2 volume unlocking requires a client ID hash (CID) to be
401           configured via fido2-cid= (see below) and a key to pass to the
402           security token's HMAC functionality (configured in the line's third
403           column) to operate. If not configured and the volume is of type
404           LUKS2, the CID and the key are read from LUKS2 JSON token metadata
405           instead. Use systemd-cryptenroll(1) as simple tool for enrolling
406           FIDO2 security tokens, compatible with this automatic mode, which
407           is only available for LUKS2 volumes.
408
409           Use systemd-cryptenroll --fido2-device=list to list all suitable
410           FIDO2 security tokens currently plugged in, along with their device
411           nodes.
412
413           This option implements the following mechanism: the configured key
414           is hashed via they HMAC keyed hash function the FIDO2 device
415           implements, keyed by a secret key embedded on the device. The
416           resulting hash value is Base64 encoded and used to unlock the LUKS2
417           volume. As it should not be possible to extract the secret from the
418           hardware token, it should not be possible to retrieve the hashed
419           key given the configured key — without possessing the hardware
420           token.
421
422           Note that many security tokens that implement FIDO2 also implement
423           PKCS#11, suitable for unlocking volumes via the pkcs11-uri= option
424           described above. Typically the newer, simpler FIDO2 standard is
425           preferable.
426
427       fido2-cid=
428           Takes a Base64 encoded FIDO2 client ID to use for the FIDO2 unlock
429           operation. If specified, but fido2-device= is not,
430           fido2-device=auto is implied. If fido2-device= is used but
431           fido2-cid= is not, the volume must be of LUKS2 type, and the CID is
432           read from the LUKS2 JSON token header. Use systemd-cryptenroll(1)
433           for enrolling a FIDO2 token in the LUKS2 header compatible with
434           this automatic mode.
435
436       fido2-rp=
437           Takes a string, configuring the FIDO2 Relying Party (rp) for the
438           FIDO2 unlock operation. If not specified "io.systemd.cryptsetup" is
439           used, except if the the LUKS2 JSON token header contains a
440           different value. It should normally not be necessary to override
441           this.
442
443       tpm2-device=
444           Takes either the special value "auto" or the path to a device node
445           (e.g.  /dev/tpmrm0) referring to a TPM2 security chip. See below
446           for an example how to set up this mechanism for unlocking an
447           encrypted volume with a TPM2 chip.
448
449           Use tpm2-pcrs= (see below) to configure the set of TPM2 PCRs to
450           bind the volume unlocking to. Use systemd-cryptenroll(1) as simple
451           tool for enrolling TPM2 security chips in LUKS2 volumes.
452
453           If specified as "auto" the TPM2 device is automatically discovered.
454           Use systemd-cryptenroll --tpm2-device=list to list all suitable
455           TPM2 devices currently available, along with their device nodes.
456
457           This option implements the following mechanism: when enrolling a
458           TPM2 device via systemd-cryptenroll on a LUKS2 volume, a randomized
459           key unlocking the volume is generated on the host and loaded into
460           the TPM2 chip where it is encrypted with an asymmetric "primary"
461           key pair derived from the TPM2's internal "seed" key. Neither the
462           seed key nor the primary key are permitted to ever leave the TPM2
463           chip — however, the now encrypted randomized key may. It is saved
464           in the LUKS2 volume JSON token header. When unlocking the encrypted
465           volume, the primary key pair is generated on the TPM2 chip again
466           (which works as long as the chip's seed key is correctly maintained
467           by the TPM2 chip), which is then used to decrypt (on the TPM2 chip)
468           the encrypted key from the LUKS2 volume JSON token header saved
469           there during enrollment. The resulting decrypted key is then used
470           to unlock the volume. When the randomized key is encrypted the
471           current values of the selected PCRs (see below) are included in the
472           operation, so that different PCR state results in different
473           encrypted keys and the decrypted key can only be recovered if the
474           same PCR state is reproduced.
475
476       tpm2-pcrs=
477           Takes a comma separated list of numeric TPM2 PCR (i.e. "Platform
478           Configuration Register") indexes to bind the TPM2 volume unlocking
479           to. This option is only useful when TPM2 enrollment metadata is not
480           available in the LUKS2 JSON token header already, the way
481           systemd-cryptenroll writes it there. If not used (and no metadata
482           in the LUKS2 JSON token header defines it), defaults to a list of a
483           single entry: PCR 7. Assign an empty string to encode a policy that
484           binds the key to no PCRs, making the key accessible to local
485           programs regardless of the current PCR state.
486
487       try-empty-password=
488           Takes a boolean argument. If enabled, right before asking the user
489           for a password it is first attempted to unlock the volume with an
490           empty password. This is useful for systems that are initialized
491           with an encrypted volume with only an empty password set, which
492           shall be replaced with a suitable password during first boot, but
493           after activation.
494
495       x-systemd.device-timeout=
496           Specifies how long systemd should wait for a device to show up
497           before giving up on the entry. The argument is a time in seconds or
498           explicitly specified units of "s", "min", "h", "ms".
499
500       x-initrd.attach
501           Setup this encrypted block device in the initramfs, similarly to
502           systemd.mount(5) units marked with x-initrd.mount.
503
504           Although it's not necessary to mark the mount entry for the root
505           file system with x-initrd.mount, x-initrd.attach is still
506           recommended with the encrypted block device containing the root
507           file system as otherwise systemd will attempt to detach the device
508           during the regular system shutdown while it's still in use. With
509           this option the device will still be detached but later after the
510           root file system is unmounted.
511
512           All other encrypted block devices that contain file systems mounted
513           in the initramfs should use this option.
514
515       At early boot and when the system manager configuration is reloaded,
516       this file is translated into native systemd units by systemd-
517       cryptsetup-generator(8).
518

AF_UNIX KEY FILES

520       If the key file path (as specified in the third column of /etc/crypttab
521       entries, see above) refers to an AF_UNIX stream socket in the file
522       system, the key is acquired by connecting to the socket and reading the
523       key from the connection. The connection is made from an AF_UNIX socket
524       name in the abstract namespace, see unix(7) for details. The source
525       socket name is chosen according the following format:
526
527           NUL RANDOM "/cryptsetup/" VOLUME
528
529       In other words: a NUL byte (as required for abstract namespace
530       sockets), followed by a random string (consisting of alphanumeric
531       characters only), followed by the literal string "/cryptsetup/",
532       followed by the name of the volume to acquire they key for. Example
533       (for a volume "myvol"):
534
535       Example 1.
536
537           \0d7067f78d9827418/cryptsetup/myvol
538
539       Services listening on the AF_UNIX stream socket may query the source
540       socket name with getpeername(2), and use it to determine which key to
541       send, allowing a single listening socket to serve keys for a multitude
542       of volumes. If the PKCS#11 logic is used (see above) the socket source
543       name is picked in identical fashion, except that the literal string
544       "/cryptsetup-pkcs11/" is used (similar for FIDO2: "/cryptsetup-fido2/"
545       and TPM2: "/cryptsetup-tpm2/"). This is done so that services providing
546       key material know that not a secret key is requested but an encrypted
547       key that will be decrypted via the PKCS#11/FIDO2/TPM2 logic to acquire
548       the final secret key.
549

EXAMPLES

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

SEE ALSO

645       systemd(1), systemd-cryptsetup@.service(8), systemd-cryptsetup-
646       generator(8), systemd-cryptenroll(1), fstab(5), cryptsetup(8),
647       mkswap(8), mke2fs(8)
648

NOTES

650        1. RFC7512 PKCS#11 URI
651           https://tools.ietf.org/html/rfc7512
652
653        2. see documentation
654           https://developers.yubico.com/PIV/Introduction/Certificate_slots.html
655
656
657
658systemd 248                                                        CRYPTTAB(5)
Impressum