| 1 |
<?xml version='1.0'?> <!--*-nxml-*--> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="systemd-creds" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>systemd-creds</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>systemd-creds</refentrytitle> |
| 16 |
<manvolnum>1</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>systemd-creds</refname> |
| 21 |
<refpurpose>Lists, shows, encrypts and decrypts service credentials</refpurpose> |
| 22 |
</refnamediv> |
| 23 |
|
| 24 |
<refsynopsisdiv> |
| 25 |
<cmdsynopsis> |
| 26 |
<command>systemd-creds</command> |
| 27 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 28 |
<arg choice="plain">COMMAND</arg> |
| 29 |
<arg choice="opt" rep="repeat">ARGS</arg> |
| 30 |
</cmdsynopsis> |
| 31 |
</refsynopsisdiv> |
| 32 |
|
| 33 |
<refsect1> |
| 34 |
<title>Description</title> |
| 35 |
|
| 36 |
<para><command>systemd-creds</command> is a tool for listing, showing, encrypting and decrypting unit |
| 37 |
credentials. Credentials are limited-size binary or textual objects that may be passed to unit |
| 38 |
processes. They are primarily used for passing cryptographic keys (both public and private) or |
| 39 |
certificates, user account information or identity information from the host to services.</para> |
| 40 |
|
| 41 |
<para>Credentials are configured in unit files via the <varname>ImportCredential=</varname>, |
| 42 |
<varname>LoadCredential=</varname>, <varname>SetCredential=</varname>, |
| 43 |
<varname>LoadCredentialEncrypted=</varname>, and <varname>SetCredentialEncrypted=</varname> settings, see |
| 44 |
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for |
| 45 |
details.</para> |
| 46 |
|
| 47 |
<para>For further information see <ulink url="https://systemd.io/CREDENTIALS">System and Service |
| 48 |
Credentials</ulink> documentation.</para> |
| 49 |
</refsect1> |
| 50 |
|
| 51 |
<refsect1> |
| 52 |
<title>Commands</title> |
| 53 |
|
| 54 |
<para>The following commands are understood:</para> |
| 55 |
|
| 56 |
<variablelist> |
| 57 |
<varlistentry> |
| 58 |
<term><command>list</command></term> |
| 59 |
|
| 60 |
<listitem><para>Show a list of credentials passed into the current execution context. This command |
| 61 |
shows the files in the directory referenced by the <varname>$CREDENTIALS_DIRECTORY</varname> |
| 62 |
environment variable, and is intended to be executed from within service context.</para> |
| 63 |
|
| 64 |
<para>Along with each credential name, the size and security state is shown. The latter is one of |
| 65 |
<literal>secure</literal> (in case the credential is backed by unswappable memory, |
| 66 |
i.e. <literal>ramfs</literal>), <literal>weak</literal> (in case it is backed by any other type of |
| 67 |
memory), or <literal>insecure</literal> (if having any access mode that is not 0400, i.e. if readable |
| 68 |
by anyone but the owner).</para> |
| 69 |
|
| 70 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 71 |
</varlistentry> |
| 72 |
|
| 73 |
<varlistentry> |
| 74 |
<term><command>cat</command> <replaceable>credential...</replaceable></term> |
| 75 |
|
| 76 |
<listitem><para>Show contents of specified credentials passed into the current execution |
| 77 |
context. Takes one or more credential names, whose contents shall be written to standard |
| 78 |
output.</para> |
| 79 |
|
| 80 |
<para>When combined with <option>--json=</option> or <option>--transcode=</option> the output is |
| 81 |
transcoded in simple ways before outputting.</para> |
| 82 |
|
| 83 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 84 |
</varlistentry> |
| 85 |
|
| 86 |
<varlistentry> |
| 87 |
<term><command>setup</command></term> |
| 88 |
|
| 89 |
<listitem><para>Generates a host encryption key for credentials, if one has not been generated |
| 90 |
already. This ensures the <filename>/var/lib/systemd/credential.secret</filename> file is initialized |
| 91 |
with a random secret key if it does not exist yet. This secret key is used when encrypting/decrypting |
| 92 |
credentials with <command>encrypt</command> or <command>decrypt</command>, and is only accessible to |
| 93 |
the root user. Note that there's typically no need to invoke this command explicitly as it is |
| 94 |
implicitly called when <command>encrypt</command> is invoked, and credential host key encryption |
| 95 |
selected.</para> |
| 96 |
|
| 97 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 98 |
</varlistentry> |
| 99 |
|
| 100 |
<varlistentry> |
| 101 |
<term><command>encrypt</command> <replaceable>input|-</replaceable> <replaceable>output|-</replaceable></term> |
| 102 |
|
| 103 |
<listitem><para>Loads the specified (unencrypted plaintext) input credential file, encrypts it and |
| 104 |
writes the (encrypted ciphertext) output to the specified target credential file. The resulting file |
| 105 |
may be referenced in the <varname>LoadCredentialEncrypted=</varname> setting in unit files, or its |
| 106 |
contents used literally in <varname>SetCredentialEncrypted=</varname> settings.</para> |
| 107 |
|
| 108 |
<para>Takes two file system paths. The file name part of the output path is embedded as name in the |
| 109 |
encrypted credential, to ensure encrypted credentials cannot be renamed and reused for different |
| 110 |
purposes without this being noticed. The credential name to embed may be overridden with the |
| 111 |
<option>--name=</option> setting. The input or output paths may be specified as <literal>-</literal>, |
| 112 |
in which case the credential data is read from/written to standard input and standard output. If the |
| 113 |
output path is specified as <literal>-</literal> the credential name cannot be derived from the file |
| 114 |
system path, and thus should be specified explicitly via the <option>--name=</option> switch.</para> |
| 115 |
|
| 116 |
<para>The credential data is encrypted and authenticated symmetrically with one of the following |
| 117 |
encryption keys:</para> |
| 118 |
|
| 119 |
<orderedlist> |
| 120 |
<listitem><para>A secret key automatically derived from the system's TPM2 chip. This encryption key |
| 121 |
is not stored on the host system and thus decryption is only possible with access to the original |
| 122 |
TPM2 chip. Or in other words, the credential secured in this way can only be decrypted again by the |
| 123 |
local machine.</para></listitem> |
| 124 |
|
| 125 |
<listitem><para>A secret key stored in the <filename>/var/lib/systemd/credential.secret</filename> |
| 126 |
file which is only accessible to the root user. This "host" encryption key is stored on the host |
| 127 |
file system, and thus decryption is possible with access to the host file system and sufficient |
| 128 |
privileges. The key is automatically generated when needed, but can also be created explicitly with |
| 129 |
the <command>setup</command> command, see above.</para></listitem> |
| 130 |
|
| 131 |
<listitem><para>A combination of the above: an encryption key derived from both the TPM2 chip and |
| 132 |
the host file system. This means decryption requires both access to the original TPM2 chip and the |
| 133 |
OS installation. This is the default mode of operation if a TPM2 chip is available and |
| 134 |
<filename>/var/lib/systemd/</filename> resides on persistent media.</para></listitem> |
| 135 |
</orderedlist> |
| 136 |
|
| 137 |
<para>Which of the three keys shall be used for encryption may be configured with the |
| 138 |
<option>--with-key=</option> switch. Depending on the use-case for the encrypted credential the key |
| 139 |
to use may differ. For example, for credentials that shall be accessible from the initrd, encryption |
| 140 |
with the host key is not appropriate, since access to the host key is typically not available from |
| 141 |
the initrd. Thus, for such credentials only the TPM2 key should be used.</para> |
| 142 |
|
| 143 |
<para>Encrypted credentials are always encoded in Base64.</para> |
| 144 |
|
| 145 |
<para>Use <command>decrypt</command> (see below) to undo the encryption operation, and acquire the |
| 146 |
decrypted plaintext credential from the encrypted ciphertext credential.</para> |
| 147 |
|
| 148 |
<para>The credential data is encrypted using AES256-GCM, i.e. providing both confidentiality and |
| 149 |
integrity, keyed by a SHA256 hash of one or both of the secret keys described above.</para> |
| 150 |
|
| 151 |
<xi:include href="version-info.xml" xpointer="v250"/> |
| 152 |
</listitem> |
| 153 |
</varlistentry> |
| 154 |
|
| 155 |
<varlistentry> |
| 156 |
<term><command>decrypt</command> <replaceable>input|-</replaceable> |
| 157 |
<optional><replaceable>output|-</replaceable></optional></term> |
| 158 |
|
| 159 |
<listitem><para>Undoes the effect of the <command>encrypt</command> operation: loads the specified |
| 160 |
(encrypted ciphertext) input credential file, decrypts and authenticates it and writes the (decrypted |
| 161 |
plaintext) output to the specified target credential file.</para> |
| 162 |
|
| 163 |
<para>Takes one or two file system paths. The file name part of the input path is compared with the |
| 164 |
credential name embedded in the encrypted file. If it does not match decryption fails. This is done |
| 165 |
in order to ensure that encrypted credentials are not re-purposed without this being detected. The |
| 166 |
credential name to compare with the embedded credential name may also be overridden with the |
| 167 |
<option>--name=</option> switch. If the input path is specified as <literal>-</literal>, the |
| 168 |
encrypted credential is read from standard input. If only one path is specified or the output path |
| 169 |
specified as <literal>-</literal>, the decrypted credential is written to standard output. In this |
| 170 |
mode, the expected name embedded in the credential cannot be derived from the path and should be |
| 171 |
specified explicitly with <option>--name=</option>.</para> |
| 172 |
|
| 173 |
<para>Decrypting credentials requires access to the original TPM2 chip and/or credentials host key, |
| 174 |
see above. Information about which keys are required is embedded in the encrypted credential data, |
| 175 |
and thus decryption is entirely automatic.</para> |
| 176 |
|
| 177 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 178 |
</varlistentry> |
| 179 |
|
| 180 |
<xi:include href="standard-options.xml" xpointer="no-ask-password" /> |
| 181 |
<xi:include href="standard-options.xml" xpointer="help" /> |
| 182 |
<xi:include href="standard-options.xml" xpointer="version" /> |
| 183 |
</variablelist> |
| 184 |
</refsect1> |
| 185 |
|
| 186 |
<refsect1> |
| 187 |
<title>Options</title> |
| 188 |
|
| 189 |
<variablelist> |
| 190 |
|
| 191 |
<varlistentry> |
| 192 |
<term><option>--system</option></term> |
| 193 |
|
| 194 |
<listitem><para>When specified with the <command>list</command> and <command>cat</command> commands |
| 195 |
operates on the credentials passed to system as a whole instead of on those passed to the current |
| 196 |
execution context. This is useful in container environments where credentials may be passed in from |
| 197 |
the container manager.</para> |
| 198 |
|
| 199 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 200 |
</varlistentry> |
| 201 |
|
| 202 |
<varlistentry> |
| 203 |
<term><option>--user</option></term> |
| 204 |
|
| 205 |
<listitem><para>When specified with the <command>encrypt</command> and <command>decrypt</command> |
| 206 |
commands encrypts a user-scoped (rather than a system-scoped) credential. Use <option>--uid=</option> |
| 207 |
to select which user the credential is from. Such credentials may only be decrypted from the |
| 208 |
specified user's context, except if privileges can be acquired. Generally, when an encrypted |
| 209 |
credential shall be used in the per-user service manager it should be encrypted with this option set, |
| 210 |
when it shall be used in the system service manager it should be encrypted without.</para> |
| 211 |
|
| 212 |
<para>Internally, this ensures that the selected user's numeric UID and username, as well as the |
| 213 |
system's |
| 214 |
<citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> are |
| 215 |
incorporated into the encryption key.</para> |
| 216 |
|
| 217 |
<xi:include href="version-info.xml" xpointer="v256"/></listitem> |
| 218 |
</varlistentry> |
| 219 |
|
| 220 |
<varlistentry> |
| 221 |
<term><option>--uid=</option></term> |
| 222 |
|
| 223 |
<listitem><para>Specifies the user to encrypt the credential for. Takes a user name or numeric |
| 224 |
UID. If set, implies <option>--user</option>. If set to the special string <literal>self</literal> |
| 225 |
sets the user to the user of the calling process. If <option>--user</option> is used without |
| 226 |
<option>--uid=</option> then <option>--uid=self</option> is implied, i.e. the credential is encrypted |
| 227 |
for the calling user.</para> |
| 228 |
|
| 229 |
<xi:include href="version-info.xml" xpointer="v256"/></listitem> |
| 230 |
</varlistentry> |
| 231 |
|
| 232 |
<varlistentry> |
| 233 |
<term><option>--transcode=</option></term> |
| 234 |
|
| 235 |
<listitem><para>When specified with the <command>cat</command> or <command>decrypt</command> |
| 236 |
commands, transcodes the output before showing it. Takes one of <literal>base64</literal>, |
| 237 |
<literal>unbase64</literal>, <literal>hex</literal> or <literal>unhex</literal> as argument, in order |
| 238 |
to encode/decode the credential data with Base64 or as series of hexadecimal values. The special |
| 239 |
value <literal>help</literal> may be used to list supported transcode types.</para> |
| 240 |
|
| 241 |
<para>Note that this has no effect on the <command>encrypt</command> command, as encrypted |
| 242 |
credentials are unconditionally encoded in Base64.</para> |
| 243 |
|
| 244 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 245 |
</varlistentry> |
| 246 |
|
| 247 |
<varlistentry> |
| 248 |
<term><option>--newline=</option></term> |
| 249 |
|
| 250 |
<listitem><para>When specified with <command>cat</command> or <command>decrypt</command> controls |
| 251 |
whether to add a trailing newline character to the end of the output if it does not end in one, |
| 252 |
anyway. Takes one of <literal>auto</literal>, <literal>yes</literal> or <literal>no</literal>. The |
| 253 |
default mode of <literal>auto</literal> will suffix the output with a single newline character only |
| 254 |
when writing credential data to a TTY.</para> |
| 255 |
|
| 256 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 257 |
</varlistentry> |
| 258 |
|
| 259 |
<varlistentry> |
| 260 |
<term><option>--pretty</option></term> |
| 261 |
<term><option>-p</option></term> |
| 262 |
|
| 263 |
<listitem><para>When specified with <command>encrypt</command> controls whether to show the encrypted |
| 264 |
credential as <varname>SetCredentialEncrypted=</varname> setting that may be pasted directly into a |
| 265 |
unit file. Has effect only when used together with <option>--name=</option> and <literal>-</literal> |
| 266 |
as the output file.</para> |
| 267 |
|
| 268 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 269 |
</varlistentry> |
| 270 |
|
| 271 |
<varlistentry> |
| 272 |
<term><option>--name=<replaceable>name</replaceable></option></term> |
| 273 |
|
| 274 |
<listitem><para>When specified with the <command>encrypt</command> command controls the credential |
| 275 |
name to embed in the encrypted credential data. If not specified, the name is chosen automatically |
| 276 |
from the filename component of the specified output path. If specified as empty string no |
| 277 |
credential name is embedded in the encrypted credential, and no verification of credential name is |
| 278 |
done when the credential is decrypted.</para> |
| 279 |
|
| 280 |
<para>When specified with the <command>decrypt</command> command control the credential name to |
| 281 |
validate the credential name embedded in the encrypted credential with. If not specified, the name is |
| 282 |
chosen automatically from the filename component of the specified input path. If no credential name |
| 283 |
is embedded in the encrypted credential file (i.e. the <option>--name=</option> with an empty string |
| 284 |
was used when encrypted) the specified name has no effect as no credential name validation is |
| 285 |
done.</para> |
| 286 |
|
| 287 |
<para>Embedding the credential name in the encrypted credential is done in order to protect against |
| 288 |
reuse of credentials for purposes they were not originally intended for, under the assumption the |
| 289 |
credential name is chosen carefully to encode its intended purpose.</para> |
| 290 |
|
| 291 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 292 |
</varlistentry> |
| 293 |
|
| 294 |
<varlistentry> |
| 295 |
<term><option>--timestamp=<replaceable>timestamp</replaceable></option></term> |
| 296 |
|
| 297 |
<listitem><para>When specified with the <command>encrypt</command> command controls the timestamp to |
| 298 |
embed into the encrypted credential. Defaults to the current time. Takes a timestamp specification in |
| 299 |
the format described in |
| 300 |
<citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para> |
| 301 |
|
| 302 |
<para>When specified with the <command>decrypt</command> command controls the timestamp to use to |
| 303 |
validate the "not-after" timestamp that was configured with <option>--not-after=</option> during |
| 304 |
encryption. If not specified, defaults to the current system time.</para> |
| 305 |
|
| 306 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 307 |
</varlistentry> |
| 308 |
|
| 309 |
<varlistentry> |
| 310 |
<term><option>--not-after=<replaceable>timestamp</replaceable></option></term> |
| 311 |
|
| 312 |
<listitem><para>When specified with the <command>encrypt</command> command controls the time when the |
| 313 |
credential shall not be used anymore. This embeds the specified timestamp in the encrypted |
| 314 |
credential. During decryption the timestamp is checked against the current system clock, and if the |
| 315 |
timestamp is in the past the decryption will fail. By default, no such timestamp is set. Takes a |
| 316 |
timestamp specification in the format described in |
| 317 |
<citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para> |
| 318 |
|
| 319 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 320 |
</varlistentry> |
| 321 |
|
| 322 |
<varlistentry> |
| 323 |
<term><option>--with-key=</option></term> |
| 324 |
<term><option>-H</option></term> |
| 325 |
<term><option>-T</option></term> |
| 326 |
|
| 327 |
<listitem><para>When specified with the <command>encrypt</command> command controls the |
| 328 |
encryption/signature key to use. Takes one of <literal>host</literal>, <literal>tpm2</literal>, |
| 329 |
<literal>host+tpm2</literal>, <literal>null</literal>, <literal>auto</literal>, |
| 330 |
<literal>auto-initrd</literal>. See above for details on the key types. If set to |
| 331 |
<literal>auto</literal> (which is the default) the TPM2 key is used if a TPM2 device is found and not |
| 332 |
running in a container. The host key is used if <filename>/var/lib/systemd/</filename> is on |
| 333 |
persistent media. This means on typical systems the encryption is by default bound to both the TPM2 |
| 334 |
chip and the OS installation, and both need to be available to decrypt the credential again. If |
| 335 |
<literal>auto</literal> is selected but neither TPM2 is available (or running in container) nor |
| 336 |
<filename>/var/lib/systemd/</filename> is on persistent media, encryption will fail. If set to |
| 337 |
<literal>null</literal> a fixed zero length key is used (thus, in this mode no confidentiality nor |
| 338 |
authenticity are provided!). This logic is useful to cover for systems that lack a TPM2 chip but |
| 339 |
where credentials shall be generated. Note that decryption of such credentials is refused on systems |
| 340 |
that have a TPM2 chip and where UEFI SecureBoot is enabled (this is done so that such a locked down |
| 341 |
system cannot be tricked into loading a credential generated this way that lacks authentication |
| 342 |
information. If either UEFI SecureBoot or a TPM2 are not available, then loading such credentials is |
| 343 |
allowed by default). If set to <literal>auto-initrd</literal> a TPM2 key is used if a TPM2 is found. |
| 344 |
If not, a fixed zero length key is used, equivalent to <literal>null</literal> mode. This option is |
| 345 |
particularly useful to generate credentials files that are encrypted/authenticated against TPM2 where |
| 346 |
available but still work on systems lacking support for this. The special value |
| 347 |
<literal>help</literal> may be used to list supported key types.</para> |
| 348 |
|
| 349 |
<para>The <option>-H</option> switch is a shortcut for <option>--with-key=host</option>. Similar, |
| 350 |
<option>-T</option> is a shortcut for <option>--with-key=tpm2</option>.</para> |
| 351 |
|
| 352 |
<para>When encrypting credentials that shall be used in the initrd (where |
| 353 |
<filename>/var/lib/systemd/</filename> is typically not available) make sure to use |
| 354 |
<option>--with-key=auto-initrd</option> mode, to disable binding against the host secret.</para> |
| 355 |
|
| 356 |
<para>This switch has no effect on the <command>decrypt</command> command, as information on which |
| 357 |
key to use for decryption is included in the encrypted credential already.</para> |
| 358 |
|
| 359 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 360 |
</varlistentry> |
| 361 |
|
| 362 |
<varlistentry> |
| 363 |
<term><option>--tpm2-device=<replaceable>PATH</replaceable></option></term> |
| 364 |
|
| 365 |
<listitem><para>Controls the TPM2 device to use. Expects a device node path referring to the TPM2 |
| 366 |
chip (e.g. <filename>/dev/tpmrm0</filename>). Alternatively the special value <literal>auto</literal> |
| 367 |
may be specified, in order to automatically determine the device node of a suitable TPM2 device (of |
| 368 |
which there must be exactly one). The special value <literal>list</literal> may be used to enumerate |
| 369 |
all suitable TPM2 devices currently discovered.</para> |
| 370 |
|
| 371 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 372 |
</varlistentry> |
| 373 |
|
| 374 |
<varlistentry> |
| 375 |
<term><option>--tpm2-pcrs=<replaceable>PCR<optional>+PCR...</optional></replaceable></option></term> |
| 376 |
|
| 377 |
<listitem><para>Configures the TPM2 PCRs (Platform Configuration Registers) to bind the encryption |
| 378 |
key to. Takes a <literal>+</literal> separated list of numeric PCR indexes in the range 0…23. If an |
| 379 |
empty string is specified, binds the encryption key to no PCRs at all (this is also the default if |
| 380 |
this option is not used). For details about the PCRs available, see the documentation of the switch |
| 381 |
of the same name for |
| 382 |
<citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> |
| 383 |
|
| 384 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 385 |
</varlistentry> |
| 386 |
|
| 387 |
<varlistentry> |
| 388 |
<term><option>--tpm2-public-key=<replaceable>PATH</replaceable></option></term> |
| 389 |
<term><option>--tpm2-public-key-pcrs=<replaceable>PCR<optional>+PCR...</optional></replaceable></option></term> |
| 390 |
|
| 391 |
<listitem><para>Configures a TPM2 signed PCR policy to bind encryption to, for use with the |
| 392 |
<command>encrypt</command> command. The <option>--tpm2-public-key=</option> option accepts a path to |
| 393 |
a PEM encoded RSA public key, to bind the encryption to. If this is not specified explicitly, but a |
| 394 |
file <filename>tpm2-pcr-public-key.pem</filename> exists in one of the directories |
| 395 |
<filename>/etc/systemd/</filename>, <filename>/run/systemd/</filename>, |
| 396 |
<filename>/usr/lib/systemd/</filename> (searched in this order), it is automatically used. The |
| 397 |
<option>--tpm2-public-key-pcrs=</option> option takes a list of TPM2 PCR indexes to bind to (same |
| 398 |
syntax as <option>--tpm2-pcrs=</option> described above). If not specified, defaults to 11 (i.e. this |
| 399 |
binds the policy to any unified kernel image for which a PCR signature can be provided).</para> |
| 400 |
|
| 401 |
<para>Note the difference between <option>--tpm2-pcrs=</option> and |
| 402 |
<option>--tpm2-public-key-pcrs=</option>: the former binds decryption to the current, specific PCR |
| 403 |
values; the latter binds decryption to any set of PCR values for which a signature by the specified |
| 404 |
public key can be provided. The latter is hence more useful in scenarios where software updates shall |
| 405 |
be possible without losing access to all previously encrypted secrets.</para> |
| 406 |
|
| 407 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 408 |
</varlistentry> |
| 409 |
|
| 410 |
<varlistentry> |
| 411 |
<term><option>--tpm2-signature=<replaceable>PATH</replaceable></option></term> |
| 412 |
|
| 413 |
<listitem><para>Takes a path to a TPM2 PCR signature file as generated by the |
| 414 |
<citerefentry><refentrytitle>systemd-measure</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 415 |
tool and that may be used to allow the <command>decrypt</command> command to decrypt credentials that |
| 416 |
are bound to specific signed PCR values. If this is not specified explicitly, and a credential |
| 417 |
with a signed PCR policy is attempted to be decrypted, a suitable signature file |
| 418 |
<filename>tpm2-pcr-signature.json</filename> is searched for in <filename>/etc/systemd/</filename>, |
| 419 |
<filename>/run/systemd/</filename>, <filename>/usr/lib/systemd/</filename> (in this order) and |
| 420 |
used.</para> |
| 421 |
|
| 422 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 423 |
</varlistentry> |
| 424 |
|
| 425 |
<varlistentry> |
| 426 |
<term><option>--allow-null</option></term> |
| 427 |
|
| 428 |
<listitem><para>Allow decrypting credentials that use a null key. By default decryption of |
| 429 |
credentials encrypted/authenticated with a null key is only allowed if UEFI SecureBoot is off or if |
| 430 |
a TPM2 is not available.</para> |
| 431 |
|
| 432 |
<xi:include href="version-info.xml" xpointer="v256"/></listitem> |
| 433 |
</varlistentry> |
| 434 |
|
| 435 |
<varlistentry> |
| 436 |
<term><option>--refuse-null</option></term> |
| 437 |
|
| 438 |
<listitem><para>Refuse decrypting credentials that use a null key, regardless of the UEFI SecureBoot |
| 439 |
state or TPM2 availability (see above).</para> |
| 440 |
|
| 441 |
<xi:include href="version-info.xml" xpointer="v259"/></listitem> |
| 442 |
</varlistentry> |
| 443 |
|
| 444 |
<varlistentry> |
| 445 |
<term><option>--quiet</option></term> |
| 446 |
<term><option>-q</option></term> |
| 447 |
|
| 448 |
<listitem><para>Suppress additional output.</para> |
| 449 |
|
| 450 |
<xi:include href="version-info.xml" xpointer="v251"/></listitem> |
| 451 |
</varlistentry> |
| 452 |
|
| 453 |
<xi:include href="standard-options.xml" xpointer="no-pager" /> |
| 454 |
<xi:include href="standard-options.xml" xpointer="no-legend" /> |
| 455 |
<xi:include href="standard-options.xml" xpointer="json" /> |
| 456 |
</variablelist> |
| 457 |
</refsect1> |
| 458 |
|
| 459 |
<refsect1> |
| 460 |
<title>Exit status</title> |
| 461 |
|
| 462 |
<para>On success, 0 is returned.</para> |
| 463 |
</refsect1> |
| 464 |
|
| 465 |
<refsect1> |
| 466 |
<title>Examples</title> |
| 467 |
|
| 468 |
<example> |
| 469 |
<title>Encrypt a password for use as credential</title> |
| 470 |
|
| 471 |
<para>The following command line encrypts the specified password <literal>hunter2</literal>, writing the result |
| 472 |
to a file <filename>password.cred</filename>.</para> |
| 473 |
|
| 474 |
<programlisting># echo -n hunter2 | systemd-creds encrypt - password.cred</programlisting> |
| 475 |
|
| 476 |
<para>This decrypts the file <filename>password.cred</filename> again, revealing the literal password:</para> |
| 477 |
|
| 478 |
<programlisting># systemd-creds decrypt password.cred |
| 479 |
hunter2</programlisting> |
| 480 |
</example> |
| 481 |
|
| 482 |
<example> |
| 483 |
<title>Encrypt a password and include it in a unit file</title> |
| 484 |
|
| 485 |
<para>The following command line prompts the user for a password and generates a |
| 486 |
<varname>SetCredentialEncrypted=</varname> line from it for a credential named |
| 487 |
<literal>mysql-password</literal>, suitable for inclusion in a unit file.</para> |
| 488 |
|
| 489 |
<programlisting># systemd-ask-password -n | systemd-creds encrypt --name=mysql-password -p - - |
| 490 |
🔐 Password: **** |
| 491 |
SetCredentialEncrypted=mysql-password: \ |
| 492 |
k6iUCUh0RJCQyvL8k8q1UyAAAAABAAAADAAAABAAAAASfFsBoPLIm/dlDoGAAAAAAAAAA \ |
| 493 |
NAAAAAgAAAAAH4AILIOZ3w6rTzYsBy9G7liaCAd4i+Kpvs8mAgArzwuKxd0ABDjgSeO5k \ |
| 494 |
mKQc58zM94ZffyRmuNeX1lVHE+9e2YD87KfRFNoDLS7F3YmCb347gCiSk2an9egZ7Y0Xs \ |
| 495 |
700Kr6heqQswQEemNEc62k9RJnEl2q7SbcEYguegnPQUATgAIAAsAAAASACA/B90W7E+6 \ |
| 496 |
yAR9NgiIJvxr9bpElztwzB5lUJAxtMBHIgAQACCaSV9DradOZz4EvO/LSaRyRSq2Hj0ym \ |
| 497 |
gVJk/dVzE8Uxj8H3RbsT7rIBH02CIgm/Gv1ukSXO3DMHmVQkDG0wEciyageTfrVEer8z5 \ |
| 498 |
9cUQfM5ynSaV2UjeUWEHuz4fwDsXGLB9eELXLztzUU9nsAyLvs3ZRR+eEK/A==</programlisting> |
| 499 |
|
| 500 |
<para>The generated line can be pasted 1:1 into a unit file, and will ensure the acquired password will |
| 501 |
be made available in the <varname>$CREDENTIALS_DIRECTORY</varname><filename>/mysql-password</filename> |
| 502 |
credential file for the started service.</para> |
| 503 |
|
| 504 |
<para>Utilizing the unit file drop-in logic this can be used to securely pass a password credential to |
| 505 |
a unit. A similar, more comprehensive set of commands to insert a password into a service |
| 506 |
<filename>xyz.service</filename>:</para> |
| 507 |
|
| 508 |
<programlisting># mkdir -p /etc/systemd/system/xyz.service.d |
| 509 |
# systemd-ask-password -n | ( echo "[Service]" && systemd-creds encrypt --name=mysql-password -p - - ) >/etc/systemd/system/xyz.service.d/50-password.conf |
| 510 |
# systemctl daemon-reload |
| 511 |
# systemctl restart xyz.service</programlisting> |
| 512 |
</example> |
| 513 |
</refsect1> |
| 514 |
|
| 515 |
<refsect1> |
| 516 |
<title>See Also</title> |
| 517 |
<para><simplelist type="inline"> |
| 518 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 519 |
<member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 520 |
<member><citerefentry><refentrytitle>systemd-measure</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 521 |
</simplelist></para> |
| 522 |
</refsect1> |
| 523 |
|
| 524 |
</refentry> |