Debian Codegraph @

man/userdbctl.xml

raw
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="userdbctl" conditional='ENABLE_USERDB'
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>userdbctl</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>userdbctl</refentrytitle>
16 <manvolnum>1</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>userdbctl</refname>
21 <refpurpose>Inspect users, groups and group memberships</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <cmdsynopsis>
26 <command>userdbctl</command>
27 <arg choice="opt" rep="repeat">OPTIONS</arg>
28 <arg choice="req">COMMAND</arg>
29 <arg choice="opt" rep="repeat">NAME</arg>
30 </cmdsynopsis>
31 </refsynopsisdiv>
32
33 <refsect1>
34 <title>Description</title>
35
36 <para><command>userdbctl</command> may be used to inspect user and groups (as well as group memberships)
37 of the system. This client utility inquires user/group information provided by various system services,
38 both operating on JSON user/group records (as defined by the <ulink
39 url="https://systemd.io/USER_RECORD">JSON User Records</ulink> and <ulink
40 url="https://systemd.io/GROUP_RECORD">JSON Group Records</ulink> definitions), and classic UNIX NSS/glibc
41 user and group records. This tool is primarily a client to the <ulink
42 url="https://systemd.io/USER_GROUP_API">User/Group Record Lookup API via Varlink</ulink>, and may also
43 pick up drop-in JSON user and group records from <filename>/etc/userdb/</filename>,
44 <filename>/run/userdb/</filename>, <filename>/run/host/userdb/</filename>,
45 <filename>/usr/lib/userdb/</filename> (see
46 <citerefentry><refentrytitle>nss-systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
47 details about drop-in user records).</para>
48 </refsect1>
49
50 <refsect1>
51 <title>Options</title>
52
53 <para>The following options are understood:</para>
54
55 <variablelist>
56
57 <varlistentry>
58 <term><option>--output=<replaceable>MODE</replaceable></option></term>
59
60 <listitem><para>Chooses the output mode. Takes one of <literal>classic</literal>,
61 <literal>friendly</literal>, <literal>table</literal> or <literal>json</literal>. If
62 <literal>classic</literal>, an output very close to the format of <filename>/etc/passwd</filename> or
63 <filename>/etc/group</filename> is generated. If <literal>friendly</literal>, a more comprehensive and
64 user friendly, human-readable output is generated. If <literal>table</literal>, a minimal, tabular
65 output is generated. If <literal>json</literal>, a JSON formatted output is generated. Defaults to
66 <literal>friendly</literal> if a user/group is specified on the command line,
67 <literal>table</literal> otherwise.</para>
68
69 <para>Note that most output formats do not show all available information. In particular,
70 <literal>classic</literal> and <literal>table</literal> show only the most important fields. Various
71 modes also do not show password hashes. Use <literal>json</literal> to view all fields, including
72 any authentication fields.</para>
73
74 <xi:include href="version-info.xml" xpointer="v245"/>
75 </listitem>
76 </varlistentry>
77
78 <varlistentry>
79 <term><option>--json=<replaceable>FORMAT</replaceable></option></term>
80
81 <listitem><para>Selects JSON output mode (like <option>--output=json</option>) and selects the
82 precise display mode. Takes one of <literal>pretty</literal> or <literal>short</literal>. If
83 <literal>pretty</literal>, human-friendly whitespace and newlines are inserted in the output to make
84 the JSON data more readable. If <literal>short</literal>, all superfluous whitespace is
85 suppressed.</para>
86
87 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
88 </varlistentry>
89
90 <varlistentry>
91 <term><option>--service=<replaceable>SERVICE</replaceable><optional>:<replaceable>SERVICE…</replaceable></optional></option></term>
92 <term><option>-s</option> <replaceable>SERVICE</replaceable>:<replaceable>SERVICE…</replaceable></term>
93
94 <listitem><para>Controls which services to query for users/groups. Takes a list of one or more
95 service names, separated by <literal>:</literal>. See below for a list of well-known service
96 names. If not specified, all available services are queried at once.</para>
97
98 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
99 </varlistentry>
100
101 <varlistentry>
102 <term><option>--with-nss=<replaceable>BOOL</replaceable></option></term>
103
104 <listitem><para>Controls whether to include classic glibc/NSS user/group lookups in the output. If
105 <option>--with-nss=no</option> is used, any attempts to resolve or enumerate users/groups provided
106 only via glibc NSS is suppressed. If <option>--with-nss=yes</option> is specified, such users/groups
107 are included in the output (which is the default).</para>
108
109 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
110 </varlistentry>
111
112 <varlistentry>
113 <term><option>--with-varlink=<replaceable>BOOL</replaceable></option></term>
114
115 <listitem><para>Controls whether to include Varlink user/group lookups in the output, i.e. those done
116 via the <ulink url="https://systemd.io/USER_GROUP_API">User/Group Record Lookup API via
117 Varlink</ulink>. If <option>--with-varlink=no</option> is used, any attempts to resolve or enumerate
118 users/groups provided only via Varlink are suppressed. If <option>--with-varlink=yes</option> is
119 specified, such users/groups are included in the output (which is the default).</para>
120
121 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
122 </varlistentry>
123
124 <varlistentry>
125 <term><option>--with-dropin=<replaceable>BOOL</replaceable></option></term>
126
127 <listitem><para>Controls whether to include user/group lookups in the output that are defined using
128 drop-in files in <filename>/etc/userdb/</filename>, <filename>/run/userdb/</filename>,
129 <filename>/run/host/userdb/</filename>, <filename>/usr/lib/userdb/</filename>. If
130 <option>--with-dropin=no</option> is used, these records are suppressed. If
131 <option>--with-dropin=yes</option> is specified, such users/groups are included in the output (which
132 is the default).</para>
133
134 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
135 </varlistentry>
136
137 <varlistentry>
138 <term><option>--synthesize=<replaceable>BOOL</replaceable></option></term>
139
140 <listitem><para>Controls whether to synthesize records for the root and nobody users/groups if they
141 are not defined otherwise, as well as the user/groups for the "foreign" UID range. By default (or with
142 <literal>yes</literal>), such records are implicitly synthesized if otherwise missing since they have
143 special significance to the OS. When <literal>no</literal>, this synthesizing is turned off.</para>
144
145 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
146 </varlistentry>
147
148 <varlistentry>
149 <term><option>-N</option></term>
150
151 <listitem><para>This option is short for <option>--with-nss=no</option>
152 <option>--synthesize=no</option>. Use this option to show only records that are natively defined as
153 JSON user or group records, with all NSS/glibc compatibility and all implicit synthesis turned
154 off.</para>
155
156 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
157 </varlistentry>
158
159 <varlistentry>
160 <term><option>--multiplexer=<replaceable>BOOL</replaceable></option></term>
161
162 <listitem><para>Controls whether to do lookups via the multiplexer service (if specified as true, the
163 default) or do lookups in the client (if specified as false). Using the multiplexer service is
164 typically preferable, since it runs in a locked down sandbox.</para>
165
166 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
167 </varlistentry>
168
169 <varlistentry>
170 <term><option>--chain</option></term>
171
172 <listitem><para>When used with the <command>ssh-authorized-keys</command> command, this will allow
173 passing an additional command line after the user name that is chain executed after the lookup
174 completed. This allows chaining multiple tools that show SSH authorized keys.</para>
175
176 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
177 </varlistentry>
178
179 <varlistentry>
180 <term><option>--fuzzy</option></term>
181 <term><option>-z</option></term>
182
183 <listitem><para>When used with the <command>user</command> or <command>group</command> command, do a
184 fuzzy string search. Any specified arguments will be matched against the user name, the real name of
185 the user record, the email address, and other descriptive strings of the user or group
186 record. Moreover, instead of precise matching, a substring match or a match allowing slight
187 deviations in spelling is applied.</para>
188
189 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
190 </varlistentry>
191
192 <varlistentry>
193 <term><option>--disposition=</option></term>
194
195 <listitem><para>When used with the <command>user</command> or <command>group</command> command,
196 filters by disposition of the record. Takes one of <literal>intrinsic</literal>,
197 <literal>system</literal>, <literal>regular</literal>, <literal>dynamic</literal>,
198 <literal>container</literal>. May be used multiple times, in which case only users matching any of
199 the specified dispositions are shown.</para>
200
201 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
202 </varlistentry>
203
204 <varlistentry>
205 <term><option>-I</option></term>
206 <term><option>-S</option></term>
207 <term><option>-R</option></term>
208
209 <listitem><para>Shortcuts for <option>--disposition=intrinsic</option>,
210 <option>--disposition=system</option>, <option>--disposition=regular</option>,
211 respectively.</para>
212
213 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
214 </varlistentry>
215
216 <varlistentry>
217 <term><option>--uid-min=</option></term>
218 <term><option>--uid-max=</option></term>
219
220 <listitem><para>When used with the <command>user</command> or <command>group</command> command,
221 filters the output by UID/GID ranges. Takes numeric minimum or maximum UID/GID values, respectively. Shows only
222 records within the specified range. When applied to the <command>user</command> command, it matches
223 against UIDs. When applied to the <command>group</command> command, matches against GIDs (despite the name of
224 the switch). If unspecified, defaults to 0 (for the minimum) and 4294967294 (for the maximum), i.e. by
225 default, no filtering is applied, as the whole UID/GID range is covered.</para>
226
227 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
228 </varlistentry>
229
230 <varlistentry>
231 <term><option>--uuid=</option></term>
232
233 <listitem><para>When used with the <command>user</command> or <command>group</command> command,
234 filters the output to the record with the specified UUID. If unspecified, no UUID-based filtering is applied.</para>
235
236 <xi:include href="version-info.xml" xpointer="v259"/></listitem>
237 </varlistentry>
238
239 <varlistentry>
240 <term><option>--boundaries=</option></term>
241
242 <listitem><para>When used with the <command>user</command> or <command>group</command> command,
243 controls whether to show relevant UID/GID range boundary information in the tabular output. Takes a
244 boolean. Defaults to true.</para>
245
246 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
247 </varlistentry>
248
249 <varlistentry>
250 <term><option>-B</option></term>
251
252 <listitem><para>Shortcut for <option>--boundaries=no</option>.</para>
253
254 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
255 </varlistentry>
256
257 <varlistentry>
258 <term><option>--from-file=PATH</option></term>
259 <term><option>-F</option></term>
260
261 <listitem><para>When used with the <command>user</command> or <command>group</command> command, read
262 the user definition in JSON format from the specified file, instead of querying it from the
263 system. If the path is specified as <literal>-</literal>, reads the JSON data from standard
264 input. This is useful to validate and introspect JSON user or group records quickly, and check how
265 they would be interpreted on the local system.</para>
266
267 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
268 </varlistentry>
269
270 <xi:include href="standard-options.xml" xpointer="no-pager" />
271 <xi:include href="standard-options.xml" xpointer="no-legend" />
272 <xi:include href="standard-options.xml" xpointer="help" />
273 <xi:include href="standard-options.xml" xpointer="version" />
274 </variablelist>
275 </refsect1>
276
277 <refsect1>
278 <title>Commands</title>
279
280 <para>The following commands are understood:</para>
281
282 <variablelist>
283
284 <varlistentry>
285 <term><command>user</command> <optional><replaceable>USER</replaceable>…</optional></term>
286
287 <listitem><para>List all known users records or show details of one or more specified user
288 records. Use <option>--output=</option> to tweak output mode.</para>
289
290 <para>If used in conjunction with <option>--from-file=</option> the user record data is read in JSON
291 format from the specified file instead of querying it from the system. For details see above.</para>
292
293 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
294 </varlistentry>
295
296 <varlistentry>
297 <term><command>group</command> <optional><replaceable>GROUP</replaceable>…</optional></term>
298
299 <listitem><para>List all known group records or show details of one or more specified group
300 records. Use <option>--output=</option> to tweak the output mode.</para>
301
302 <para>If used in conjunction with <option>--from-file=</option> the group record data is read in JSON
303 format from the specified file instead of querying it from the system. For details see above.</para>
304
305 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
306 </varlistentry>
307
308 <varlistentry>
309 <term><command>users-in-group</command> <optional><replaceable>GROUP</replaceable>…</optional></term>
310
311 <listitem><para>List users that are members of the specified groups. If no groups are specified, list
312 all user/group memberships defined. Use <option>--output=</option> to tweak the output
313 mode.</para>
314
315 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
316 </varlistentry>
317
318 <varlistentry>
319 <term><command>groups-of-user</command> <optional><replaceable>USER</replaceable>…</optional></term>
320
321 <listitem><para>Lists groups that the specified users are members of. If no users are specified, lists
322 all user/group memberships defined (in this case, <command>groups-of-user</command> and
323 <command>users-in-group</command> are equivalent). Use <option>--output=</option> to tweak the output
324 mode.</para>
325
326 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
327 </varlistentry>
328
329 <varlistentry>
330 <term><command>services</command></term>
331
332 <listitem><para>List all services currently providing user/group definitions to the system. See below
333 for a list of well-known services providing user information.</para>
334
335 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
336 </varlistentry>
337
338 <varlistentry>
339 <term><command>ssh-authorized-keys</command></term>
340
341 <listitem><para>Show SSH authorized keys for this account. This command is intended to be used to
342 allow the SSH daemon to pick up authorized keys from user records, see below.</para>
343
344 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
345 </varlistentry>
346
347 <varlistentry>
348 <term><command>load-credentials</command></term>
349 <listitem>
350 <para>When specified, the following credentials are used when passed in:</para>
351
352 <variablelist>
353 <varlistentry>
354 <term><varname>userdb.user.*</varname></term>
355 <term><varname>userdb.group.*</varname></term>
356 <listitem>
357 <para>These credentials should contain valid <ulink url="https://systemd.io/USER_RECORD">JSON
358 User</ulink> and <ulink url="https://systemd.io/GROUP_RECORD">JSON Group</ulink> records. For
359 each matching credential, various files are created in <filename>/etc/userdb/</filename>,
360 implementing the interface described in
361 <citerefentry><refentrytitle>nss-systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
362 Any passed user records must contain valid UID and GID fields. Any passed group records must
363 contain a GID field (i.e. automatic UID/GID allocation is not supported). For both user and
364 group records, the credential suffix (for <literal>userdb.user.foobar</literal> the suffix is
365 <literal>foobar</literal>) must match the user or group name encoded in the record.</para>
366
367 <xi:include href="version-info.xml" xpointer="v258"/>
368 </listitem>
369 </varlistentry>
370 </variablelist>
371
372 <xi:include href="version-info.xml" xpointer="v258"/>
373 </listitem>
374 </varlistentry>
375 </variablelist>
376 </refsect1>
377
378 <refsect1>
379 <title>Well-Known Services</title>
380
381 <para>The <command>userdbctl services</command> command will list all currently running services that
382 provide user or group definitions to the system. The following well-known services are shown among
383 this list:</para>
384
385 <variablelist>
386 <varlistentry>
387 <term><constant>io.systemd.DynamicUser</constant></term>
388
389 <listitem><para>This service is provided by the system service manager itself (i.e. PID 1) and
390 makes all users (and their groups) synthesized through the <varname>DynamicUser=</varname> setting in
391 service unit files available to the system (see
392 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
393 details about this setting).</para>
394
395 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
396 </varlistentry>
397
398 <varlistentry>
399 <term><constant>io.systemd.Home</constant></term>
400
401 <listitem><para>This service is provided by
402 <citerefentry><refentrytitle>systemd-homed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
403 and makes all users (and their groups) belonging to home directories managed by that service
404 available to the system.</para>
405
406 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
407 </varlistentry>
408
409 <varlistentry>
410 <term><constant>io.systemd.Machine</constant></term>
411
412 <listitem><para>This service is provided by
413 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
414 and synthesizes records for all users/groups used by a container that employs user
415 namespacing.</para>
416
417 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
418 </varlistentry>
419
420 <varlistentry>
421 <term><constant>io.systemd.Multiplexer</constant></term>
422
423 <listitem><para>This service is provided by
424 <citerefentry><refentrytitle>systemd-userdbd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
425 and multiplexes user/group look-ups to all other running lookup services. This is the primary entry point
426 for user/group record clients, as it simplifies client side implementation substantially, since they
427 can ask a single service for lookups instead of asking all running services in parallel.
428 <command>userdbctl</command> uses this service preferably, too, unless <option>--with-nss=</option>
429 or <option>--service=</option> are used, in which case finer control over the services to talk to is
430 required.</para>
431
432 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
433 </varlistentry>
434
435 <varlistentry>
436 <term><constant>io.systemd.NameServiceSwitch</constant></term>
437
438 <listitem><para>This service is (also) provided by
439 <citerefentry><refentrytitle>systemd-userdbd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
440 and converts classic NSS/glibc user and group records to JSON user/group records, providing full
441 backwards compatibility. Use <option>--with-nss=no</option> to disable this compatibility, see
442 above. Note that compatibility is actually provided in both directions:
443 <citerefentry><refentrytitle>nss-systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry> will
444 automatically synthesize classic NSS/glibc user/group records from all JSON user/group records
445 provided to the system, thus using both APIs is mostly equivalent and provides access to the same
446 data, however the NSS/glibc APIs necessarily expose a more reduced set of fields
447 only.</para>
448
449 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
450 </varlistentry>
451
452 <varlistentry>
453 <term><constant>io.systemd.DropIn</constant></term>
454
455 <listitem><para>This service is (also) provided by
456 <citerefentry><refentrytitle>systemd-userdbd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
457 and picks up JSON user/group records from <filename>/etc/userdb/</filename>,
458 <filename>/run/userdb/</filename>, <filename>/run/host/userdb/</filename>,
459 <filename>/usr/lib/userdb/</filename>.</para>
460
461 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
462 </varlistentry>
463
464 </variablelist>
465
466 <para>Note that <command>userdbctl</command> has internal support for NSS-based lookups too. This means
467 that if neither <constant>io.systemd.Multiplexer</constant> nor
468 <constant>io.systemd.NameServiceSwitch</constant> are running, look-ups into the basic user/group
469 databases will still work.</para>
470 </refsect1>
471
472 <refsect1>
473 <title>Integration with SSH</title>
474
475 <para>The <command>userdbctl</command> tool may be used to make the list of SSH authorized keys possibly
476 contained in a user record available to the SSH daemon for authentication. For that, configure the
477 following in <citerefentry
478 project='man-pages'><refentrytitle>sshd_config</refentrytitle><manvolnum>5</manvolnum></citerefentry>:</para>
479
480 <programlisting>…
481 AuthorizedKeysCommand /usr/bin/userdbctl ssh-authorized-keys %u
482 AuthorizedKeysCommandUser root
483 …</programlisting>
484
485 <para>Sometimes, it is useful to allow chain invocation of another program to list SSH authorized keys. By
486 using the <option>--chain</option> option, such a tool may be chain executed by <command>userdbctl
487 ssh-authorized-keys</command> once a lookup completes, regardless of whether an SSH key was found or
488 not. Example:</para>
489
490 <programlisting>…
491 AuthorizedKeysCommand /usr/bin/userdbctl ssh-authorized-keys %u --chain /usr/bin/othertool %u
492 AuthorizedKeysCommandUser root
493 …</programlisting>
494
495 <para>The above will first query the userdb database for SSH keys, and then chain execute
496 <command>/usr/bin/othertool</command> to also be queried.</para>
497 </refsect1>
498
499 <refsect1>
500 <title>Exit status</title>
501
502 <para>On success, 0 is returned, and a non-zero failure code otherwise.</para>
503 </refsect1>
504
505 <xi:include href="common-variables.xml" />
506
507 <refsect1>
508 <title>See Also</title>
509 <para><simplelist type="inline">
510 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
511 <member><citerefentry><refentrytitle>systemd-userdbd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
512 <member><citerefentry><refentrytitle>systemd-homed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
513 <member><citerefentry><refentrytitle>nss-systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
514 <member><citerefentry project='man-pages'><refentrytitle>getent</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
515 </simplelist></para>
516 </refsect1>
517
518 </refentry>