| 1 |
<?xml version='1.0'?> |
| 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-ask-password" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>systemd-ask-password</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>systemd-ask-password</refentrytitle> |
| 16 |
<manvolnum>1</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>systemd-ask-password</refname> |
| 21 |
<refpurpose>Query the user for a system password</refpurpose> |
| 22 |
</refnamediv> |
| 23 |
|
| 24 |
<refsynopsisdiv> |
| 25 |
<cmdsynopsis> |
| 26 |
<command>systemd-ask-password</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt">MESSAGE</arg> |
| 27 |
</cmdsynopsis> |
| 28 |
</refsynopsisdiv> |
| 29 |
|
| 30 |
<refsect1> |
| 31 |
<title>Description</title> |
| 32 |
|
| 33 |
<para><command>systemd-ask-password</command> may be used to query a password or passphrase interactively |
| 34 |
from the user, using a question prompt specified on the command line. When run from a TTY it will query a |
| 35 |
password on the TTY and print it to standard output. When run with no TTY or with |
| 36 |
<option>--no-tty</option> it will use a system-wide or per-user agent-based query mechanism, which allows |
| 37 |
active users to respond via several agents, listed below.</para> |
| 38 |
|
| 39 |
<para>The purpose of this tool is to query system-wide or per-user passwords — the former includes |
| 40 |
passwords possibly not associated to a specific user account. Examples include: unlocking encrypted hard |
| 41 |
disks when they are plugged in or at boot, entering an SSL certificate passphrase for web and VPN |
| 42 |
servers.</para> |
| 43 |
|
| 44 |
<para>Existing system-level agents are: |
| 45 |
<itemizedlist> |
| 46 |
|
| 47 |
<listitem><para>A boot-time password agent asking the user for passwords using <citerefentry |
| 48 |
project='die-net'><refentrytitle>plymouth</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
| 49 |
</para></listitem> |
| 50 |
|
| 51 |
<listitem><para>A boot-time password agent querying the user |
| 52 |
directly on the console — |
| 53 |
<citerefentry><refentrytitle>systemd-ask-password-console.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
| 54 |
</para></listitem> |
| 55 |
|
| 56 |
<listitem><para>An agent requesting password input via a |
| 57 |
<citerefentry project='man-pages'><refentrytitle>wall</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 58 |
message — |
| 59 |
<citerefentry><refentrytitle>systemd-ask-password-wall.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
| 60 |
</para></listitem> |
| 61 |
|
| 62 |
<listitem><para>A TTY agent that is temporarily spawned during |
| 63 |
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 64 |
invocations,</para></listitem> |
| 65 |
|
| 66 |
<listitem><para>A command line agent which can be started |
| 67 |
temporarily to process queued password |
| 68 |
requests — <command>systemd-tty-ask-password-agent --query</command>. |
| 69 |
</para></listitem> |
| 70 |
</itemizedlist></para> |
| 71 |
|
| 72 |
<para>Answering system-wide password queries is a privileged operation, hence |
| 73 |
all the agents listed above (except for the last one), run as privileged |
| 74 |
system services. The last one also needs elevated privileges, so |
| 75 |
should be run through |
| 76 |
<citerefentry><refentrytitle>run0</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 77 |
or similar.</para> |
| 78 |
|
| 79 |
<para>Additional password agents may be implemented according to the <ulink |
| 80 |
url="https://systemd.io/PASSWORD_AGENTS/">systemd Password Agent Specification</ulink>.</para> |
| 81 |
|
| 82 |
<para>If a password is queried on a TTY, the user may press TAB to |
| 83 |
hide the asterisks normally shown for each character typed. |
| 84 |
Pressing Backspace as first key achieves the same effect.</para> |
| 85 |
</refsect1> |
| 86 |
|
| 87 |
<refsect1> |
| 88 |
<title>Options</title> |
| 89 |
|
| 90 |
<para>The following options are understood:</para> |
| 91 |
|
| 92 |
<variablelist> |
| 93 |
<varlistentry> |
| 94 |
<term><option>--icon=</option></term> |
| 95 |
|
| 96 |
<listitem><para>Specify an icon name alongside the password |
| 97 |
query, which may be used in all agents supporting graphical |
| 98 |
display. The icon name should follow the <ulink |
| 99 |
url="https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">XDG |
| 100 |
Icon Naming Specification</ulink>.</para></listitem> |
| 101 |
</varlistentry> |
| 102 |
|
| 103 |
<varlistentry> |
| 104 |
<term><option>--id=</option></term> |
| 105 |
<listitem><para>Specify an identifier for this password |
| 106 |
query. This identifier is freely choosable and allows |
| 107 |
recognition of queries by involved agents. It should include |
| 108 |
the subsystem doing the query and the specific object the |
| 109 |
query is done for. Example: |
| 110 |
<literal>--id=cryptsetup:/dev/sda5</literal>.</para> |
| 111 |
|
| 112 |
<xi:include href="version-info.xml" xpointer="v227"/></listitem> |
| 113 |
</varlistentry> |
| 114 |
|
| 115 |
<varlistentry> |
| 116 |
<term><option>--keyname=</option></term> |
| 117 |
<listitem><para>Configure a kernel keyring key name to use as |
| 118 |
cache for the password. If set, then the tool will try to push |
| 119 |
any collected passwords into the kernel keyring of the root |
| 120 |
user, as a key of the specified name. If combined with |
| 121 |
<option>--accept-cached</option>, it will also try to retrieve |
| 122 |
such cached passwords from the key in the kernel keyring |
| 123 |
instead of querying the user right away. By using this option, |
| 124 |
the kernel keyring may be used as effective cache to avoid |
| 125 |
repeatedly asking users for passwords, if there are multiple |
| 126 |
objects that may be unlocked with the same password. The |
| 127 |
cached key will have a timeout of 2.5min set, after which it |
| 128 |
will be purged from the kernel keyring. Note that it is |
| 129 |
possible to cache multiple passwords under the same keyname, |
| 130 |
in which case they will be stored as <constant>NUL</constant>-separated list of |
| 131 |
passwords. Use |
| 132 |
<citerefentry project='die-net'><refentrytitle>keyctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 133 |
to access the cached key via the kernel keyring |
| 134 |
directly. Example: <literal>--keyname=cryptsetup</literal></para> |
| 135 |
|
| 136 |
<xi:include href="version-info.xml" xpointer="v227"/></listitem> |
| 137 |
</varlistentry> |
| 138 |
|
| 139 |
<varlistentry> |
| 140 |
<term><option>--credential=</option></term> |
| 141 |
<listitem><para>Configure a credential to read the password from – if it exists. This may be used in |
| 142 |
conjunction with the <varname>ImportCredential=</varname>, <varname>LoadCredential=</varname> and |
| 143 |
<varname>SetCredential=</varname> settings in unit files. See |
| 144 |
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for |
| 145 |
details. If not specified, defaults to <literal>password</literal>. This option has no effect if no |
| 146 |
credentials directory is passed to the program (i.e. <varname>$CREDENTIALS_DIRECTORY</varname> is not |
| 147 |
set) or if the no credential of the specified name exists.</para> |
| 148 |
|
| 149 |
<xi:include href="version-info.xml" xpointer="v249"/></listitem> |
| 150 |
</varlistentry> |
| 151 |
|
| 152 |
<varlistentry> |
| 153 |
<term><option>--timeout=</option></term> |
| 154 |
|
| 155 |
<listitem><para>Specify the query timeout in seconds. Defaults |
| 156 |
to 90s. A timeout of 0 waits indefinitely. </para></listitem> |
| 157 |
</varlistentry> |
| 158 |
|
| 159 |
<varlistentry> |
| 160 |
<term><option>--echo=yes|no|masked</option></term> |
| 161 |
|
| 162 |
<listitem><para>Controls whether to echo user input. Takes a boolean or the special string |
| 163 |
<literal>masked</literal>, the default being the latter. If enabled the typed characters are echoed |
| 164 |
literally, which is useful for prompting for usernames and other non-protected data. If disabled the |
| 165 |
typed characters are not echoed in any form, the user will not get feedback on their input. If set to |
| 166 |
<literal>masked</literal>, an asterisk (<literal>*</literal>) is echoed for each character |
| 167 |
typed. In this mode, if the user hits the tabulator key (<literal>↹</literal>), echo is turned |
| 168 |
off. (Alternatively, if the user hits the backspace key (<literal>⌫</literal>) while no data has |
| 169 |
been entered otherwise, echo is turned off, too).</para> |
| 170 |
|
| 171 |
<xi:include href="version-info.xml" xpointer="v249"/></listitem> |
| 172 |
</varlistentry> |
| 173 |
|
| 174 |
<varlistentry> |
| 175 |
<term><option>--echo</option></term> |
| 176 |
<term><option>-e</option></term> |
| 177 |
|
| 178 |
<listitem><para>Equivalent to <option>--echo=yes</option>, see above.</para> |
| 179 |
|
| 180 |
<xi:include href="version-info.xml" xpointer="v217"/></listitem> |
| 181 |
</varlistentry> |
| 182 |
|
| 183 |
<varlistentry> |
| 184 |
<term><option>--emoji=yes|no|auto</option></term> |
| 185 |
|
| 186 |
<listitem><para>Controls whether or not to prefix the query with a |
| 187 |
lock and key emoji (🔐), if the TTY settings permit this. The default |
| 188 |
is <literal>auto</literal>, which defaults to <literal>yes</literal>, |
| 189 |
unless <option>--echo=yes</option> is given.</para> |
| 190 |
|
| 191 |
<xi:include href="version-info.xml" xpointer="v249"/></listitem> |
| 192 |
</varlistentry> |
| 193 |
|
| 194 |
<varlistentry> |
| 195 |
<term><option>--no-tty</option></term> |
| 196 |
|
| 197 |
<listitem><para>Never ask for password on current TTY even if |
| 198 |
one is available. Always use agent system.</para></listitem> |
| 199 |
</varlistentry> |
| 200 |
|
| 201 |
<varlistentry> |
| 202 |
<term><option>--accept-cached</option></term> |
| 203 |
|
| 204 |
<listitem><para>If passed, accept cached passwords, i.e. |
| 205 |
passwords previously entered.</para></listitem> |
| 206 |
</varlistentry> |
| 207 |
|
| 208 |
<varlistentry> |
| 209 |
<term><option>--multiple</option></term> |
| 210 |
|
| 211 |
<listitem><para>When used in conjunction with |
| 212 |
<option>--accept-cached</option> accept multiple passwords. |
| 213 |
This will output one password per line.</para></listitem> |
| 214 |
</varlistentry> |
| 215 |
|
| 216 |
<varlistentry> |
| 217 |
<term><option>--no-output</option></term> |
| 218 |
|
| 219 |
<listitem><para>Do not print passwords to standard output. This is useful if you want to store a |
| 220 |
password in kernel keyring with <option>--keyname=</option> but do not want it to show up on screen |
| 221 |
or in logs.</para> |
| 222 |
|
| 223 |
<xi:include href="version-info.xml" xpointer="v230"/></listitem> |
| 224 |
</varlistentry> |
| 225 |
|
| 226 |
<varlistentry> |
| 227 |
<term><option>-n</option></term> |
| 228 |
|
| 229 |
<listitem><para>By default, when the acquired password is written to standard output it is suffixed |
| 230 |
by a newline character. This may be turned off with the <option>-n</option> switch, similarly to the |
| 231 |
switch of the same name of the <citerefentry |
| 232 |
project='man-pages'><refentrytitle>echo</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 233 |
command.</para> |
| 234 |
|
| 235 |
<xi:include href="version-info.xml" xpointer="v249"/></listitem> |
| 236 |
</varlistentry> |
| 237 |
|
| 238 |
<varlistentry> |
| 239 |
<term><option>--user</option></term> |
| 240 |
<term><option>--system</option></term> |
| 241 |
|
| 242 |
<listitem><para>Controls whether to query the system-wide or the per-user password agents. By default |
| 243 |
if invoked privileged the system-wide agents are queried, otherwise the per-user ones. These options |
| 244 |
allow one to override this automatic behaviour.</para> |
| 245 |
|
| 246 |
<xi:include href="version-info.xml" xpointer="v257"/></listitem> |
| 247 |
</varlistentry> |
| 248 |
|
| 249 |
<xi:include href="standard-options.xml" xpointer="help" /> |
| 250 |
</variablelist> |
| 251 |
|
| 252 |
</refsect1> |
| 253 |
|
| 254 |
<refsect1> |
| 255 |
<title>Exit status</title> |
| 256 |
|
| 257 |
<para>On success, 0 is returned, a non-zero failure code |
| 258 |
otherwise.</para> |
| 259 |
</refsect1> |
| 260 |
|
| 261 |
<refsect1> |
| 262 |
<title>See Also</title> |
| 263 |
<para><simplelist type="inline"> |
| 264 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 265 |
<member><citerefentry><refentrytitle>systemd-ask-password-console.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 266 |
<member><citerefentry><refentrytitle>systemd-tty-ask-password-agent</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 267 |
<member><citerefentry project='die-net'><refentrytitle>keyctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 268 |
<member><citerefentry project='die-net'><refentrytitle>plymouth</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 269 |
<member><citerefentry project='man-pages'><refentrytitle>wall</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 270 |
</simplelist></para> |
| 271 |
</refsect1> |
| 272 |
|
| 273 |
</refentry> |