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'
>
9 <title>systemd-cryptenroll
</title>
10 <productname>systemd
</productname>
14 <refentrytitle>systemd-cryptenroll
</refentrytitle>
15 <manvolnum>1</manvolnum>
19 <refname>systemd-cryptenroll
</refname>
20 <refpurpose>Enroll PKCS#
11, FIDO2, TPM2 token/devices to LUKS2 encrypted volumes
</refpurpose>
25 <command>systemd-cryptenroll
<arg choice=
"opt" rep=
"repeat">OPTIONS
</arg> <arg choice=
"opt">DEVICE
</arg></command>
30 <title>Description
</title>
32 <para><command>systemd-cryptenroll
</command> is a tool for enrolling hardware security tokens and devices into a
33 LUKS2 encrypted volume, which may then be used to unlock the volume during boot. Specifically, it supports
34 tokens and credentials of the following kind to be enrolled:
</para>
37 <listitem><para>PKCS#
11 security tokens and smartcards that may carry an RSA key pair (e.g. various YubiKeys)
</para></listitem>
39 <listitem><para>FIDO2 security tokens that implement the
<literal>hmac-secret
</literal> extension (most FIDO2 keys, including YubiKeys)
</para></listitem>
41 <listitem><para>TPM2 security devices
</para></listitem>
43 <listitem><para>Recovery keys. These are similar to regular passphrases, however are randomly generated
44 on the computer and thus generally have higher entropy than user chosen passphrases. Their character
45 set has been designed to ensure they are easy to type in, while having high entropy. They may also be
46 scanned off screen using QR codes. Recovery keys may be used for unlocking LUKS2 volumes wherever
47 passphrases are accepted. They are intended to be used in combination with an enrolled hardware
48 security token, as a recovery option when the token is lost.
</para></listitem>
50 <listitem><para>Regular passphrases
</para></listitem>
53 <para>In addition, the tool may be used to enumerate currently enrolled security tokens and wipe a subset
54 of them. The latter may be combined with the enrollment operation of a new security token, in order to
55 update or replace enrollments.
</para>
57 <para>The tool supports only LUKS2 volumes, as it stores token meta-information in the LUKS2 JSON token
58 area, which is not available in other encryption formats.
</para>
62 <title>Options
</title>
64 <para>The following options are understood:
</para>
68 <term><option>--password
</option></term>
70 <listitem><para>Enroll a regular password/passphrase. This command is mostly equivalent to
71 <command>cryptsetup luksAddKey
</command>, however may be combined with
72 <option>--wipe-slot=
</option> in one call, see below.
</para></listitem>
76 <term><option>--recovery-key
</option></term>
78 <listitem><para>Enroll a recovery key. Recovery keys are most identical to passphrases, but are
79 computer generated instead of human chosen, and thus have a guaranteed high entropy. The key uses a
80 character set that is easy to type in, and may be scanned off screen via a QR code.
</para></listitem>
84 <term><option>--pkcs11-token-uri=
</option><replaceable>URI
</replaceable></term>
86 <listitem><para>Enroll a PKCS#
11 security token or smartcard (e.g. a YubiKey). Expects a PKCS#
11
87 smart card URI referring to the token. Alternatively the special value
<literal>auto
</literal> may
88 be specified, in order to automatically determine the URI of a currently plugged in security token
89 (of which there must be exactly one). The special value
<literal>list
</literal> may be used to
90 enumerate all suitable PKCS#
11 tokens currently plugged in. The security token must contain an RSA
91 key pair which is used to encrypt the randomly generated key that is used to unlock the LUKS2
92 volume. The encrypted key is then stored in the LUKS2 JSON token header area.
</para>
94 <para>In order to unlock a LUKS2 volume with an enrolled PKCS#
11 security token, specify the
95 <option>pkcs11-uri=
</option> option in the respective
<filename>/etc/crypttab
</filename> line:
</para>
97 <programlisting>myvolume /dev/sda1 - pkcs11-uri=auto
</programlisting>
100 <citerefentry><refentrytitle>crypttab
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for a
101 more comprehensive example of a
<command>systemd-cryptenroll
</command> invocation and its matching
102 <filename>/etc/crypttab
</filename> line.
</para></listitem>
106 <term><option>--fido2-device=
</option><replaceable>PATH
</replaceable></term>
108 <listitem><para>Enroll a FIDO2 security token that implements the
<literal>hmac-secret
</literal>
109 extension (e.g. a YubiKey). Expects a
<filename>hidraw
</filename> device referring to the FIDO2
110 device (e.g.
<filename>/dev/hidraw1
</filename>). Alternatively the special value
111 <literal>auto
</literal> may be specified, in order to automatically determine the device node of a
112 currently plugged in security token (of which there must be exactly one). The special value
113 <literal>list
</literal> may be used to enumerate all suitable FIDO2 tokens currently plugged in. Note
114 that many hardware security tokens that implement FIDO2 also implement the older PKCS#
11
115 standard. Typically FIDO2 is preferable, given it's simpler to use and more modern.
</para>
117 <para>In order to unlock a LUKS2 volume with an enrolled FIDO2 security token, specify the
118 <option>fido2-device=
</option> option in the respective
<filename>/etc/crypttab
</filename> line:
</para>
120 <programlisting>myvolume /dev/sda1 - fido2-device=auto
</programlisting>
123 <citerefentry><refentrytitle>crypttab
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for a
124 more comprehensive example of a
<command>systemd-cryptenroll
</command> invocation and its matching
125 <filename>/etc/crypttab
</filename> line.
</para></listitem>
129 <term><option>--fido2-with-client-pin=
</option><replaceable>BOOL
</replaceable></term>
131 <listitem><para>When enrolling a FIDO2 security token, controls whether to require the user to enter
132 a PIN when unlocking the volume (the FIDO2
<literal>clientPin
</literal> feature). Defaults to
133 <literal>yes
</literal>. (Note: this setting is without effect if the security token does not support
134 the
<literal>clientPin
</literal> feature at all, or does not allow enabling or disabling
135 it.)
</para></listitem>
139 <term><option>--fido2-with-user-presence=
</option><replaceable>BOOL
</replaceable></term>
141 <listitem><para>When enrolling a FIDO2 security token, controls whether to require the user to
142 verify presence (tap the token, the FIDO2
<literal>up
</literal> feature) when unlocking the volume.
143 Defaults to
<literal>yes
</literal>. (Note: this setting is without effect if the security token does not support
144 the
<literal>up
</literal> feature at all, or does not allow enabling or disabling it.)
149 <term><option>--fido2-with-user-verification=
</option><replaceable>BOOL
</replaceable></term>
151 <listitem><para>When enrolling a FIDO2 security token, controls whether to require user verification
152 when unlocking the volume (the FIDO2
<literal>uv
</literal> feature). Defaults to
153 <literal>no
</literal>. (Note: this setting is without effect if the security token does not support
154 the
<literal>uv
</literal> feature at all, or does not allow enabling or disabling it.)
</para></listitem>
158 <term><option>--tpm2-device=
</option><replaceable>PATH
</replaceable></term>
160 <listitem><para>Enroll a TPM2 security chip. Expects a device node path referring to the TPM2 chip
161 (e.g.
<filename>/dev/tpmrm0
</filename>). Alternatively the special value
<literal>auto
</literal> may
162 be specified, in order to automatically determine the device node of a currently discovered TPM2
163 device (of which there must be exactly one). The special value
<literal>list
</literal> may be used to
164 enumerate all suitable TPM2 devices currently discovered.
</para>
166 <para>In order to unlock a LUKS2 volume with an enrolled TPM2 security chip, specify the
167 <option>tpm2-device=
</option> option in the respective
<filename>/etc/crypttab
</filename> line:
</para>
169 <programlisting>myvolume /dev/sda1 - tpm2-device=auto
</programlisting>
172 <citerefentry><refentrytitle>crypttab
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for a
173 more comprehensive example of a
<command>systemd-cryptenroll
</command> invocation and its matching
174 <filename>/etc/crypttab
</filename> line.
</para>
176 <para>Use
<option>--tpm2-pcrs=
</option> (see below) to configure which TPM2 PCR indexes to bind the
177 enrollment to.
</para></listitem>
181 <term><option>--tpm2-pcrs=
</option><arg rep=
"repeat">PCR
</arg></term>
183 <listitem><para>Configures the TPM2 PCRs (Platform Configuration Registers) to bind the enrollment
184 requested via
<option>--tpm2-device=
</option> to. Takes a
<literal>+
</literal> separated list of
185 numeric PCR indexes in the range
0…
23. If not used, defaults to PCR
7 only. If an empty string is
186 specified, binds the enrollment to no PCRs at all. PCRs allow binding the enrollment to specific
187 software versions and system state, so that the enrolled unlocking key is only accessible (may be
188 "unsealed") if specific trusted software and/or configuration is used.
</para></listitem>
191 <title>Well-known PCR Definitions
</title>
193 <tgroup cols='
2' align='left' colsep='
1' rowsep='
1'
>
194 <colspec colname=
"pcr" />
195 <colspec colname=
"definition" />
200 <entry>Explanation
</entry>
207 <entry>Core system firmware executable code; changes on firmware updates
</entry>
212 <entry>Core system firmware data/host platform configuration; typically contains serial and model numbers, changes on basic hardware/CPU/RAM replacements
</entry>
217 <entry>Extended or pluggable executable code; includes option ROMs on pluggable hardware
</entry>
222 <entry>Extended or pluggable firmware data; includes information about pluggable hardware
</entry>
227 <entry>Boot loader; changes on boot loader updates
</entry>
232 <entry>GPT/Partition table; changes when the partitions are added, modified or removed
</entry>
237 <entry>Power state events; changes on system suspend/sleep
</entry>
242 <entry>Secure boot state; changes when UEFI SecureBoot mode is enabled/disabled
</entry>
247 <entry><citerefentry><refentrytitle>sd-boot
</refentrytitle><manvolnum>7</manvolnum></citerefentry> measures the kernel command line in this PCR.
</entry>
256 <term><option>--wipe-slot=
</option><arg rep=
"repeat">SLOT
</arg></term>
258 <listitem><para>Wipes one or more LUKS2 key slots. Takes a comma separated list of numeric slot
259 indexes, or the special strings
<literal>all
</literal> (for wiping all key slots),
260 <literal>empty
</literal> (for wiping all key slots that are unlocked by an empty passphrase),
261 <literal>password
</literal> (for wiping all key slots that are unlocked by a traditional passphrase),
262 <literal>recovery
</literal> (for wiping all key slots that are unlocked by a recovery key),
263 <literal>pkcs11
</literal> (for wiping all key slots that are unlocked by a PKCS#
11 token),
264 <literal>fido2
</literal> (for wiping all key slots that are unlocked by a FIDO2 token),
265 <literal>tpm2
</literal> (for wiping all key slots that are unlocked by a TPM2 chip), or any
266 combination of these strings or numeric indexes, in which case all slots matching either are
267 wiped. As safety precaution an operation that wipes all slots without exception (so that the volume
268 cannot be unlocked at all anymore, unless the volume key is known) is refused.
</para>
270 <para>This switch may be used alone, in which case only the requested wipe operation is executed. It
271 may also be used in combination with any of the enrollment options listed above, in which case the
272 enrollment is completed first, and only when successful the wipe operation executed — and the newly
273 added slot is always excluded from the wiping. Combining enrollment and slot wiping may thus be used to
274 update existing enrollments:
</para>
276 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=tpm2 --tpm2-device=auto
</programlisting>
278 <para>The above command will enroll the TPM2 chip, and then wipe all previously created TPM2
279 enrollments on the LUKS2 volume, leaving only the newly created one. Combining wiping and enrollment
280 may also be used to replace enrollments of different types, for example for changing from a PKCS#
11
281 enrollment to a FIDO2 one:
</para>
283 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=pkcs11 --fido2-device=auto
</programlisting>
285 <para>Or for replacing an enrolled empty password by TPM2:
</para>
287 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=empty --tpm2-device=auto
</programlisting>
291 <xi:include href=
"standard-options.xml" xpointer=
"help" />
292 <xi:include href=
"standard-options.xml" xpointer=
"version" />
298 <title>Exit status
</title>
300 <para>On success,
0 is returned, a non-zero failure code otherwise.
</para>
304 <title>See Also
</title>
306 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
307 <citerefentry><refentrytitle>systemd-cryptsetup@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
308 <citerefentry><refentrytitle>crypttab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
309 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>