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>--tpm2-device=
</option><replaceable>PATH
</replaceable></term>
131 <listitem><para>Enroll a TPM2 security chip. Expects a device node path referring to the TPM2 chip
132 (e.g.
<filename>/dev/tpmrm0
</filename>). Alternatively the special value
<literal>auto
</literal> may
133 be specified, in order to automatically determine the device node of a currently discovered TPM2
134 device (of which there must be exactly one). The special value
<literal>list
</literal> may be used to
135 enumerate all suitable TPM2 devices currently discovered.
</para>
137 <para>In order to unlock a LUKS2 volume with an enrolled TPM2 security chip, specify the
138 <option>tpm2-device=
</option> option in the respective
<filename>/etc/crypttab
</filename> line:
</para>
140 <programlisting>myvolume /dev/sda1 - tpm2-device=auto
</programlisting>
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>
147 <para>Use
<option>--tpm2-pcrs=
</option> (see below) to configure which TPM2 PCR indexes to bind the
148 enrollment to.
</para></listitem>
152 <term><option>--tpm2-pcrs=
</option><arg rep=
"repeat">PCR
</arg></term>
154 <listitem><para>Configures the TPM2 PCRs (Platform Configuration Registers) to bind the enrollment
155 requested via
<option>--tpm2-device=
</option> to. Takes a comma separated list of numeric PCR indexes
156 in the range
0…
23. If not used, defaults to PCR
7 only. If an empty string is specified, binds the
157 enrollment to no PCRs at all. PCRs allow binding the enrollment to specific software versions and
158 system state, so that the enrolled unlocking key is only accessible (may be
"unsealed") if specific
159 trusted software and/or configuration is used.
</para></listitem>
162 <title>Well-known PCR Definitions
</title>
164 <tgroup cols='
2' align='left' colsep='
1' rowsep='
1'
>
165 <colspec colname=
"pcr" />
166 <colspec colname=
"definition" />
171 <entry>Explanation
</entry>
178 <entry>Core system firmware executable code; changes on firmware updates
</entry>
183 <entry>Core system firmware data/host platform configuration; typically contains serial and model numbers, changes on basic hardware/CPU/RAM replacements
</entry>
188 <entry>Extended or pluggable executable code; includes option ROMs on pluggable hardware
</entry>
193 <entry>Extended or pluggable firmware data; includes information about pluggable hardware
</entry>
198 <entry>Boot loader; changes on boot loader updates
</entry>
203 <entry>GPT/Partition table; changes when the partitions are added, modified or removed
</entry>
208 <entry>Power state events; changes on system suspend/sleep
</entry>
213 <entry>Secure boot state; changes when UEFI SecureBoot mode is enabled/disabled
</entry>
218 <entry><citerefentry><refentrytitle>sd-boot
</refentrytitle><manvolnum>7</manvolnum></citerefentry> measures the kernel command line in this PCR.
</entry>
227 <term><option>--wipe-slot=
</option><arg rep=
"repeat">SLOT
</arg></term>
229 <listitem><para>Wipes one or more LUKS2 key slots. Takes a comma separated list of numeric slot
230 indexes, or the special strings
<literal>all
</literal> (for wiping all key slots),
231 <literal>empty
</literal> (for wiping all key slots that are unlocked by an empty passphrase),
232 <literal>password
</literal> (for wiping all key slots that are unlocked by a traditional passphrase),
233 <literal>recovery
</literal> (for wiping all key slots that are unlocked by a recovery key),
234 <literal>pkcs11
</literal> (for wiping all key slots that are unlocked by a PKCS#
11 token),
235 <literal>fido2
</literal> (for wiping all key slots that are unlocked by a FIDO2 token),
236 <literal>tpm2
</literal> (for wiping all key slots that are unlocked by a TPM2 chip), or any
237 combination of these strings or numeric indexes, in which case all slots matching either are
238 wiped. As safety precaution an operation that wipes all slots without exception (so that the volume
239 cannot be unlocked at all anymore, unless the volume key is known) is refused.
</para>
241 <para>This switch may be used alone, in which case only the requested wipe operation is executed. It
242 may also be used in combination with any of the enrollment options listed above, in which case the
243 enrollment is completed first, and only when successful the wipe operation executed — and the newly
244 added slot is always excluded from the wiping. Combining enrollment and slot wiping may thus be used to
245 update existing enrollments:
</para>
247 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=tpm2 --tpm2-device=auto
</programlisting>
249 <para>The above command will enroll the TPM2 chip, and then wipe all previously created TPM2
250 enrollments on the LUKS2 volume, leaving only the newly created one. Combining wiping and enrollment
251 may also be used to replace enrollments of different types, for example for changing from a PKCS#
11
252 enrollment to a FIDO2 one:
</para>
254 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=pkcs11 --fido2-device=auto
</programlisting>
256 <para>Or for replacing an enrolled empty password by TPM2:
</para>
258 <programlisting>systemd-cryptenroll /dev/sda1 --wipe-slot=empty --tpm2-device=auto
</programlisting>
262 <xi:include href=
"standard-options.xml" xpointer=
"help" />
263 <xi:include href=
"standard-options.xml" xpointer=
"version" />
269 <title>Exit status
</title>
271 <para>On success,
0 is returned, a non-zero failure code otherwise.
</para>
275 <title>See Also
</title>
277 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
278 <citerefentry><refentrytitle>systemd-cryptsetup@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
279 <citerefentry><refentrytitle>crypttab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
280 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>