]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd-cryptenroll.xml
hwdb: Fix rotation for HP Pro Tablet 408 G1
[thirdparty/systemd.git] / man / systemd-cryptenroll.xml
CommitLineData
cf1e172d
LP
1<?xml version="1.0"?>
2<!--*-nxml-*-->
3<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6<refentry id="systemd-cryptenroll" xmlns:xi="http://www.w3.org/2001/XInclude" conditional='HAVE_LIBCRYPTSETUP'>
7
8 <refentryinfo>
9 <title>systemd-cryptenroll</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>systemd-cryptenroll</refentrytitle>
15 <manvolnum>1</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>systemd-cryptenroll</refname>
20 <refpurpose>Enroll PKCS#11, FIDO2, TPM2 token/devices to LUKS2 encrypted volumes</refpurpose>
21 </refnamediv>
22
23 <refsynopsisdiv>
24 <cmdsynopsis>
25 <command>systemd-cryptenroll <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt">DEVICE</arg></command>
26 </cmdsynopsis>
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
880e1e07
ZJS
32 <para><command>systemd-cryptenroll</command> is a tool for enrolling hardware security tokens and devices
33 into a LUKS2 encrypted volume, which may then be used to unlock the volume during boot. Specifically, it
34 supports tokens and credentials of the following kind to be enrolled:</para>
cf1e172d
LP
35
36 <orderedlist>
880e1e07
ZJS
37 <listitem><para>PKCS#11 security tokens and smartcards that may carry an RSA key pair (e.g. various
38 YubiKeys)</para></listitem>
cf1e172d 39
880e1e07
ZJS
40 <listitem><para>FIDO2 security tokens that implement the <literal>hmac-secret</literal> extension (most
41 FIDO2 keys, including YubiKeys)</para></listitem>
cf1e172d
LP
42
43 <listitem><para>TPM2 security devices</para></listitem>
44
a587a16a
ZJS
45 <listitem><para>Regular passphrases</para></listitem>
46
cf1e172d 47 <listitem><para>Recovery keys. These are similar to regular passphrases, however are randomly generated
880e1e07 48 on the computer and thus generally have higher entropy than user-chosen passphrases. Their character
cf1e172d
LP
49 set has been designed to ensure they are easy to type in, while having high entropy. They may also be
50 scanned off screen using QR codes. Recovery keys may be used for unlocking LUKS2 volumes wherever
51 passphrases are accepted. They are intended to be used in combination with an enrolled hardware
52 security token, as a recovery option when the token is lost.</para></listitem>
cf1e172d
LP
53 </orderedlist>
54
55 <para>In addition, the tool may be used to enumerate currently enrolled security tokens and wipe a subset
56 of them. The latter may be combined with the enrollment operation of a new security token, in order to
57 update or replace enrollments.</para>
58
59 <para>The tool supports only LUKS2 volumes, as it stores token meta-information in the LUKS2 JSON token
60 area, which is not available in other encryption formats.</para>
61 </refsect1>
0bada3f8
LP
62
63 <refsect1>
64 <title>Limitations</title>
65
66 <para>Note that currently when enrolling a new key of one of the five supported types listed above, it is
67 required to first provide a passphrase or recovery key (i.e. one of the latter two key types). For
68 example, it's currently not possible to unlock a device with a FIDO2 key in order to enroll a new FIDO2
69 key. Instead, in order to enroll a new FIDO2 key, it is necessary to provide an already enrolled regular
70 passphrase or recovery key. Thus, if in future key roll-over is desired it's generally recommended to
71 combine TPM2, FIDO2, PKCS#11 key enrollment with enrolling a regular passphrase or recovery key.</para>
72
73 <para>Also note that support for enrolling multiple FIDO2 tokens is currently not too useful, as while
74 unlocking <command>systemd-cryptsetup</command> cannot identify which token is currently plugged in and
75 thus does not know which authentication request to send to the device. This limitation does not apply to
76 tokens enrolled via PKCS#11 — because tokens of this type may be identified immediately, before
77 authentication.</para>
78 </refsect1>
cf1e172d
LP
79
80 <refsect1>
81 <title>Options</title>
82
83 <para>The following options are understood:</para>
84
85 <variablelist>
86 <varlistentry>
87 <term><option>--password</option></term>
88
89 <listitem><para>Enroll a regular password/passphrase. This command is mostly equivalent to
90 <command>cryptsetup luksAddKey</command>, however may be combined with
91 <option>--wipe-slot=</option> in one call, see below.</para></listitem>
92 </varlistentry>
93
94 <varlistentry>
95 <term><option>--recovery-key</option></term>
96
880e1e07
ZJS
97 <listitem><para>Enroll a recovery key. Recovery keys are mostly identical to passphrases, but are
98 computer-generated instead of being chosen by a human, and thus have a guaranteed high entropy. The
99 key uses a character set that is easy to type in, and may be scanned off screen via a QR code.
100 </para></listitem>
cf1e172d
LP
101 </varlistentry>
102
103 <varlistentry>
104 <term><option>--pkcs11-token-uri=</option><replaceable>URI</replaceable></term>
105
106 <listitem><para>Enroll a PKCS#11 security token or smartcard (e.g. a YubiKey). Expects a PKCS#11
be0d27ee 107 smartcard URI referring to the token. Alternatively the special value <literal>auto</literal> may
cf1e172d
LP
108 be specified, in order to automatically determine the URI of a currently plugged in security token
109 (of which there must be exactly one). The special value <literal>list</literal> may be used to
110 enumerate all suitable PKCS#11 tokens currently plugged in. The security token must contain an RSA
111 key pair which is used to encrypt the randomly generated key that is used to unlock the LUKS2
112 volume. The encrypted key is then stored in the LUKS2 JSON token header area.</para>
113
114 <para>In order to unlock a LUKS2 volume with an enrolled PKCS#11 security token, specify the
115 <option>pkcs11-uri=</option> option in the respective <filename>/etc/crypttab</filename> line:</para>
116
117 <programlisting>myvolume /dev/sda1 - pkcs11-uri=auto</programlisting>
118
119 <para>See
120 <citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>5</manvolnum></citerefentry> for a
121 more comprehensive example of a <command>systemd-cryptenroll</command> invocation and its matching
122 <filename>/etc/crypttab</filename> line.</para></listitem>
123 </varlistentry>
124
125 <varlistentry>
126 <term><option>--fido2-device=</option><replaceable>PATH</replaceable></term>
127
128 <listitem><para>Enroll a FIDO2 security token that implements the <literal>hmac-secret</literal>
129 extension (e.g. a YubiKey). Expects a <filename>hidraw</filename> device referring to the FIDO2
130 device (e.g. <filename>/dev/hidraw1</filename>). Alternatively the special value
131 <literal>auto</literal> may be specified, in order to automatically determine the device node of a
132 currently plugged in security token (of which there must be exactly one). The special value
133 <literal>list</literal> may be used to enumerate all suitable FIDO2 tokens currently plugged in. Note
134 that many hardware security tokens that implement FIDO2 also implement the older PKCS#11
135 standard. Typically FIDO2 is preferable, given it's simpler to use and more modern.</para>
136
137 <para>In order to unlock a LUKS2 volume with an enrolled FIDO2 security token, specify the
138 <option>fido2-device=</option> option in the respective <filename>/etc/crypttab</filename> line:</para>
139
140 <programlisting>myvolume /dev/sda1 - fido2-device=auto</programlisting>
141
142 <para>See
143 <citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>5</manvolnum></citerefentry> for a
144 more comprehensive example of a <command>systemd-cryptenroll</command> invocation and its matching
145 <filename>/etc/crypttab</filename> line.</para></listitem>
146 </varlistentry>
147
cde2f860
LB
148 <varlistentry>
149 <term><option>--fido2-with-client-pin=</option><replaceable>BOOL</replaceable></term>
150
72c15422
LP
151 <listitem><para>When enrolling a FIDO2 security token, controls whether to require the user to enter
152 a PIN when unlocking the volume (the FIDO2 <literal>clientPin</literal> feature). Defaults to
153 <literal>yes</literal>. (Note: this setting is without effect if the security token does not support
154 the <literal>clientPin</literal> feature at all, or does not allow enabling or disabling
155 it.)</para></listitem>
cde2f860
LB
156 </varlistentry>
157
06f08719
LB
158 <varlistentry>
159 <term><option>--fido2-with-user-presence=</option><replaceable>BOOL</replaceable></term>
160
161 <listitem><para>When enrolling a FIDO2 security token, controls whether to require the user to
162 verify presence (tap the token, the FIDO2 <literal>up</literal> feature) when unlocking the volume.
72c15422
LP
163 Defaults to <literal>yes</literal>. (Note: this setting is without effect if the security token does not support
164 the <literal>up</literal> feature at all, or does not allow enabling or disabling it.)
06f08719
LB
165 </para></listitem>
166 </varlistentry>
167
896cc0da
LB
168 <varlistentry>
169 <term><option>--fido2-with-user-verification=</option><replaceable>BOOL</replaceable></term>
170
171 <listitem><para>When enrolling a FIDO2 security token, controls whether to require user verification
72c15422
LP
172 when unlocking the volume (the FIDO2 <literal>uv</literal> feature). Defaults to
173 <literal>no</literal>. (Note: this setting is without effect if the security token does not support
174 the <literal>uv</literal> feature at all, or does not allow enabling or disabling it.)</para></listitem>
896cc0da
LB
175 </varlistentry>
176
cf1e172d
LP
177 <varlistentry>
178 <term><option>--tpm2-device=</option><replaceable>PATH</replaceable></term>
179
180 <listitem><para>Enroll a TPM2 security chip. Expects a device node path referring to the TPM2 chip
181 (e.g. <filename>/dev/tpmrm0</filename>). Alternatively the special value <literal>auto</literal> may
182 be specified, in order to automatically determine the device node of a currently discovered TPM2
183 device (of which there must be exactly one). The special value <literal>list</literal> may be used to
184 enumerate all suitable TPM2 devices currently discovered.</para>
185
186 <para>In order to unlock a LUKS2 volume with an enrolled TPM2 security chip, specify the
187 <option>tpm2-device=</option> option in the respective <filename>/etc/crypttab</filename> line:</para>
188
189 <programlisting>myvolume /dev/sda1 - tpm2-device=auto</programlisting>
190
191 <para>See
192 <citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>5</manvolnum></citerefentry> for a
193 more comprehensive example of a <command>systemd-cryptenroll</command> invocation and its matching
194 <filename>/etc/crypttab</filename> line.</para>
195
196 <para>Use <option>--tpm2-pcrs=</option> (see below) to configure which TPM2 PCR indexes to bind the
197 enrollment to.</para></listitem>
198 </varlistentry>
199
200 <varlistentry>
201 <term><option>--tpm2-pcrs=</option><arg rep="repeat">PCR</arg></term>
202
203 <listitem><para>Configures the TPM2 PCRs (Platform Configuration Registers) to bind the enrollment
a1788a69
LP
204 requested via <option>--tpm2-device=</option> to. Takes a <literal>+</literal> separated list of
205 numeric PCR indexes in the range 0…23. If not used, defaults to PCR 7 only. If an empty string is
206 specified, binds the enrollment to no PCRs at all. PCRs allow binding the enrollment to specific
207 software versions and system state, so that the enrolled unlocking key is only accessible (may be
9a89ab26 208 "unsealed") if specific trusted software and/or configuration is used.</para>
cf1e172d
LP
209
210 <table>
211 <title>Well-known PCR Definitions</title>
212
9a89ab26
LP
213 <!-- See: https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/ -->
214 <!-- See: https://github.com/rhboot/shim/blob/main/README.tpm -->
215 <!-- See: https://www.gnu.org/software/grub/manual/grub/html_node/Measured-Boot.html -->
216 <!-- See: https://sourceforge.net/p/linux-ima/wiki/Home/ -->
27818e2e
LP
217 <!-- See: https://github.com/tianocore-docs/edk2-TrustedBootChain/blob/main/4_Other_Trusted_Boot_Chains.md -->
218 <!-- See: https://wiki.archlinux.org/title/Trusted_Platform_Module#Accessing_PCR_registers -->
9a89ab26 219
cf1e172d
LP
220 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
221 <colspec colname="pcr" />
222 <colspec colname="definition" />
223
224 <thead>
225 <row>
226 <entry>PCR</entry>
227 <entry>Explanation</entry>
228 </row>
229 </thead>
230
231 <tbody>
232 <row>
233 <entry>0</entry>
234 <entry>Core system firmware executable code; changes on firmware updates</entry>
235 </row>
236
237 <row>
238 <entry>1</entry>
239 <entry>Core system firmware data/host platform configuration; typically contains serial and model numbers, changes on basic hardware/CPU/RAM replacements</entry>
240 </row>
241
242 <row>
243 <entry>2</entry>
244 <entry>Extended or pluggable executable code; includes option ROMs on pluggable hardware</entry>
245 </row>
246
247 <row>
248 <entry>3</entry>
249 <entry>Extended or pluggable firmware data; includes information about pluggable hardware</entry>
250 </row>
251
252 <row>
253 <entry>4</entry>
ebf3ee41 254 <entry>Boot loader and additional drivers; changes on boot loader updates. The shim project will measure the PE binary it chain loads into this PCR. If the Linux kernel is invoked as UEFI PE binary, it is measured here, too. <citerefentry><refentrytitle>sd-stub</refentrytitle><manvolnum>7</manvolnum></citerefentry> measures system extension images read from the ESP here too (see <citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry>).</entry>
cf1e172d
LP
255 </row>
256
257 <row>
258 <entry>5</entry>
259 <entry>GPT/Partition table; changes when the partitions are added, modified or removed</entry>
260 </row>
261
262 <row>
263 <entry>6</entry>
264 <entry>Power state events; changes on system suspend/sleep</entry>
265 </row>
266
267 <row>
268 <entry>7</entry>
9a89ab26 269 <entry>Secure boot state; changes when UEFI SecureBoot mode is enabled/disabled, or firmware certificates (PK, KEK, db, dbx, …) changes. The shim project will measure most of its (non-MOK) certificates and SBAT data into this PCR.</entry>
cf1e172d
LP
270 </row>
271
27818e2e
LP
272 <!-- Grub measures all its commands and the kernel command line into PCR 8… -->
273 <!-- Grub measures all files it reads (including kernel image, initrd, …) into PCR 9… -->
274
cf1e172d 275 <row>
ebf3ee41
LP
276 <entry>9</entry>
277 <entry>The Linux kernel measures all initial RAM file systems it receives into this PCR.</entry>
278 <!-- Strictly speaking only Linux >= 5.17 using the LOAD_FILE2 protocol, see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f046fff8bc4c4d8f8a478022e76e40b818f692df -->
9a89ab26
LP
279 </row>
280
9a89ab26
LP
281 <row>
282 <entry>10</entry>
283 <entry>The IMA project measures its runtime state into this PCR.</entry>
284 </row>
285
ebf3ee41
LP
286 <row>
287 <entry>12</entry>
288 <entry><citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry> measures any specified kernel command line into this PCR. <citerefentry><refentrytitle>systemd-stub</refentrytitle><manvolnum>7</manvolnum></citerefentry> measures any manually specified kernel command line (i.e. a kernel command line that overrides the one embedded in the unified PE image) and loaded credentials into this PCR. (Note that if <command>sytemd-boot</command> and <command>systemd-stub</command> are used in combination the command line might be measured twice!)</entry>
289 </row>
290
9a89ab26
LP
291 <row>
292 <entry>14</entry>
293 <entry>The shim project measures its "MOK" certificates and hashes into this PCR.</entry>
cf1e172d
LP
294 </row>
295 </tbody>
296 </tgroup>
297 </table>
298
9a89ab26
LP
299 <para>For most applications it should be sufficient to bind against PCR 7 (and possibly PCR 14, if
300 shim/MOK is desired), as this includes measurements of the trusted certificates (and possibly hashes)
301 that are used to validate all components of the boot process up to and including the OS kernel. In
302 order to simplify firmware and OS version updates it's typically not advisable to include PCRs such
303 as 0 and 2 in the binding of the enrollment, since the program code they cover should already be
304 protected indirectly through the certificates measured into PCR 7. Validation through these
305 certificates is typically preferable over validation through direct measurements as it is less
306 brittle in context of OS/firmware updates: the measurements will change on every update, but code
307 signatures likely will validate against pre-existing certificates.</para></listitem>
cf1e172d
LP
308 </varlistentry>
309
caeb5604
GG
310 <varlistentry>
311 <term><option>--tpm2-with-pin=</option><replaceable>BOOL</replaceable></term>
312
313 <listitem><para>When enrolling a TPM2 device, controls whether to require the user to enter a PIN
314 when unlocking the volume in addition to PCR binding, based on TPM2 policy authentication. Defaults
315 to <literal>no</literal>. Despite being called PIN, any character can be used, not just numbers.
316 </para>
317
318 <para>Note that incorrect PIN entry when unlocking increments the
319 TPM dictionary attack lockout mechanism, and may lock out users for a prolonged time, depending on
320 its configuration. The lockout mechanism is a global property of the TPM,
321 <command>systemd-cryptenroll</command> does not control or configure the lockout mechanism. You may
322 use tpm2-tss tools to inspect or configure the dictionary attack lockout, with
ff9412c1
ZJS
323 <citerefentry project='mankier'><refentrytitle>tpm2_getcap</refentrytitle><manvolnum>1</manvolnum></citerefentry> and
324 <citerefentry project='mankier'><refentrytitle>tpm2_dictionarylockout</refentrytitle><manvolnum>1</manvolnum></citerefentry>
caeb5604
GG
325 commands, respectively.</para></listitem>
326 </varlistentry>
327
cf1e172d
LP
328 <varlistentry>
329 <term><option>--wipe-slot=</option><arg rep="repeat">SLOT</arg></term>
330
331 <listitem><para>Wipes one or more LUKS2 key slots. Takes a comma separated list of numeric slot
332 indexes, or the special strings <literal>all</literal> (for wiping all key slots),
333 <literal>empty</literal> (for wiping all key slots that are unlocked by an empty passphrase),
334 <literal>password</literal> (for wiping all key slots that are unlocked by a traditional passphrase),
335 <literal>recovery</literal> (for wiping all key slots that are unlocked by a recovery key),
336 <literal>pkcs11</literal> (for wiping all key slots that are unlocked by a PKCS#11 token),
337 <literal>fido2</literal> (for wiping all key slots that are unlocked by a FIDO2 token),
338 <literal>tpm2</literal> (for wiping all key slots that are unlocked by a TPM2 chip), or any
339 combination of these strings or numeric indexes, in which case all slots matching either are
340 wiped. As safety precaution an operation that wipes all slots without exception (so that the volume
341 cannot be unlocked at all anymore, unless the volume key is known) is refused.</para>
342
343 <para>This switch may be used alone, in which case only the requested wipe operation is executed. It
344 may also be used in combination with any of the enrollment options listed above, in which case the
345 enrollment is completed first, and only when successful the wipe operation executed — and the newly
346 added slot is always excluded from the wiping. Combining enrollment and slot wiping may thus be used to
347 update existing enrollments:</para>
348
349 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=tpm2 --tpm2-device=auto</programlisting>
350
45861042 351 <para>The above command will enroll the TPM2 chip, and then wipe all previously created TPM2
cf1e172d
LP
352 enrollments on the LUKS2 volume, leaving only the newly created one. Combining wiping and enrollment
353 may also be used to replace enrollments of different types, for example for changing from a PKCS#11
354 enrollment to a FIDO2 one:</para>
355
356 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=pkcs11 --fido2-device=auto</programlisting>
357
358 <para>Or for replacing an enrolled empty password by TPM2:</para>
359
360 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=empty --tpm2-device=auto</programlisting>
361 </listitem>
362 </varlistentry>
363
364 <xi:include href="standard-options.xml" xpointer="help" />
365 <xi:include href="standard-options.xml" xpointer="version" />
366 </variablelist>
367
368 </refsect1>
369
370 <refsect1>
371 <title>Exit status</title>
372
373 <para>On success, 0 is returned, a non-zero failure code otherwise.</para>
374 </refsect1>
375
376 <refsect1>
377 <title>See Also</title>
378 <para>
379 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
380 <citerefentry><refentrytitle>systemd-cryptsetup@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
381 <citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
382 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
383 </para>
384 </refsect1>
385
386</refentry>