]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/homectl.xml
polkit: tweak grammar
[thirdparty/systemd.git] / man / homectl.xml
CommitLineData
ea7a19e9
LP
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.2/docbookx.dtd">
4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
5
6<refentry id="homectl" conditional='ENABLE_HOMED'
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>homectl</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>homectl</refentrytitle>
16 <manvolnum>1</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>homectl</refname>
21 <refpurpose>Create, remove, change or inspect home directories</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <cmdsynopsis>
26 <command>homectl</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>homectl</command> may be used to create, remove, change or inspect a user's home
37 directory. It's primarily a command interfacing with
38 <citerefentry><refentrytitle>systemd-homed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
39 which manages home directories of users.</para>
40
41 <para>Home directories managed by <filename>systemd-homed.service</filename> are self-contained, and thus
42 include the user's full metadata record in the home's data storage itself, making them easily migratable
43 between machines. In particular a home directory in itself describes a matching user record, and every
44 user record managed by <filename>systemd-homed.service</filename> also implies existance and
45 encapsulation of a home directory. The user account and home directory hence become the same concept. The
46 following backing storage mechanisms are supported:</para>
47
48 <itemizedlist>
49 <listitem><para>Individual LUKS2 encrypted loopback files for each user, located in
50 <filename>/home/*.home</filename>. At login the file systems contained in these files are mounted,
51 after the LUKS2 encrypted volume is attached. The user's password is identical to the encryption
52 passphrase of the LUKS2 volume. Access to data without preceeding user authentication is thus not
53 possible, not even for the systems administrator. This storage mechanism provides the strongest data
54 security and is thus recommended.</para></listitem>
55
56 <listitem><para>Similar, but the LUKS2 encrypted file system is located on regular block device, such
57 as an USB storage stick. In this mode home directories and all data they include are nicely migratable
58 between machines, simply by plugging the USB stick into different systems at different
59 times.</para></listitem>
60
61 <listitem><para>An encrypted directory using <literal>fscrypt</literal> on file systems that support it
62 (at the moment this is primarily <literal>ext4</literal>), located in
63 <filename>/home/*.homedir</filename>. This mechanism also provides encryption, but substantially
64 weaker than the two mechanisms described above, as most file system metadata is unprotected. Moreover
65 it currently does not support changing user passwords once the home directory has been
66 created.</para></listitem>
67
68 <listitem><para>A <literal>btrfs</literal> subvolume for each user, also located in
69 <filename>/home/*.homedir</filename>. This provides no encryption, but good quota
70 support.</para></listitem>
71
72 <listitem><para>A regular directory for each user, also located in
73 <filename>/home/*.homedir</filename>. This provides no encryption, but is a suitable fallback
74 available on all machines, even where LUKS2, <literal>fscrypt</literal> or <literal>btrfs</literal>
75 support is not available.</para></listitem>
76
77 <listitem><para>An individual Windows file share (CIFS) for each user.</para></listitem>
78 </itemizedlist>
79
80 <para>Note that <filename>systemd-homed.service</filename> and <command>homectl</command> will not manage
81 "classic" UNIX user accounts as created with <citerefentry
82 project='man-pages'><refentrytitle>useradd</refentrytitle><manvolnum>8</manvolnum></citerefentry> or
83 similar tools. In particular, this functionality is not suitable for managing system users (i.e. users
84 with a UID below 1000) but is exclusive to regular ("human") users.</para>
85
86 <para>Note that users/home directories managed via <command>systemd-homed.service</command> do not show
87 up in <filename>/etc/passwd</filename> and similar files, they are synthesized via glibc NSS during
88 runtime. They are thus resolvable and may be enumerated via the <citerefentry
89 project='man-pages'><refentrytitle>getent</refentrytitle><manvolnum>1</manvolnum></citerefentry>
90 tool.</para>
91
92 <para>This tool interfaces directly with <filename>systemd-homed.service</filename>, and may execute
93 specific commands on the home directories it manages. Since every home directory managed that way also
94 defines a JSON user and group record these home directories may also be inspected and enumerated via
95 <citerefentry><refentrytitle>userdbctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
96
97 <para>Home directories managed by <filename>systemd-homed.service</filename> are usually in one of two
98 states, or in a transition state between them: when <literal>active</literal> they are unlocked and
99 mounted, and thus accessible to the system and its programs; when <literal>inactive</literal> they are
100 not mounted and thus not accessible. Activation happens automatically at log-in of the user and usually
101 can only complete after a password (or other authentication token) has been supplied. Deactivation
102 happens after the user fully logged out. A home directory remains active as long as the user is logged in
103 at least once, i.e. has at least one login session. When the user logs in a second time simultaneously
104 the home directory remains active. It is deactivated only after the last of the user's sessions
105 ends.</para>
106 </refsect1>
107
108 <refsect1>
109 <title>Options</title>
110
111 <para>The following general options are understood (further options that control the various properties
112 of user records managed by <filename>systemd-homed.service</filename> are documented further
113 down):</para>
114
115 <variablelist>
116
117 <varlistentry>
118 <term><option>--identity=</option><replaceable>FILE</replaceable></term>
119
120 <listitem><para>Read the user's JSON record from the specified file. If passed as
121 <literal>-</literal> reads the user record from standard input. The supplied JSON object must follow
122 the structure documented on <ulink url="https://systemd.io/USER_RECORDS">JSON User
123 Records</ulink>. This option may be used in conjunction with the <command>create</command> and
124 <command>update</command> commands (see below), where it allows configuring the user record in JSON
125 as-is, instead of setting the individual user record properties (see below).</para></listitem>
126 </varlistentry>
127
128 <varlistentry>
129 <term><option>--json=</option><replaceable>FORMAT</replaceable></term>
130 <term><option>-J</option></term>
131
132 <listitem><para>Controls whether to output the user record in JSON format, if the
133 <command>inspect</command> command (see below) is used. Takes one of <literal>pretty</literal>,
134 <literal>short</literal> or <literal>off</literal>. If <literal>pretty</literal> human-friendly
135 whitespace and newlines are inserted in the output to make the JSON data more readable. If
136 <literal>short</literal> all superfluous whitespace is suppressed. If <literal>off</literal> (the
137 default) the user information is not shown in JSON format but in a friendly human readable formatting
138 instead. The <option>-J</option> option picks <literal>pretty</literal> when run interactively and
139 <literal>short</literal> otherwise.</para></listitem>
140 </varlistentry>
141
142 <varlistentry>
143 <term><option>--export-format=</option><replaceable>FORMAT</replaceable></term>
144 <term><option>-E</option></term>
145 <term><option>-EE</option></term>
146
147 <listitem><para>When used with the <command>inspect</command> verb in JSON mode (see above) may be
148 used to suppress certain aspects of the JSON user record on output. Specifically, if
149 <literal>stripped</literal> format is used the binding and runtime fields of the record are
150 removed. If <literal>minimal</literal> format is used the cryptographic signature is removed too. If
151 <literal>full</literal> format is used the full JSON record is shown (this is the default). This
152 option is useful for copying an existing user record to a different system in order to create a
153 similar user there with the same settings. Specifically: <command>homectl inspect -EE | ssh
154 root@othersystem homectl create -i-</command> may be used as simple command line for replicating a
155 user on another host. <option>-E</option> is equivalent to <option>-j --export-format=stripped</option>,
156 <option>-EE</option> to <option>-j --export-format=minimal</option>. Note that when replicating user
157 accounts user records acquired in <literal>stripped</literal> mode will retain the original
158 cryptographic signatures and thus may only modified when the private key to update them is available
159 on the destination machine. When replicating users in <literal>minimal</literal> mode the signature
160 is remove during the replication and thus it is implicitly signed with the key of the destination
161 machine and thus may be updated there without any private key replication.</para></listitem>
162 </varlistentry>
163
164 <xi:include href="user-system-options.xml" xpointer="host" />
165 <xi:include href="user-system-options.xml" xpointer="machine" />
166
167 <xi:include href="standard-options.xml" xpointer="no-pager" />
168 <xi:include href="standard-options.xml" xpointer="no-legend" />
169 <xi:include href="standard-options.xml" xpointer="no-ask-password" />
170 <xi:include href="standard-options.xml" xpointer="help" />
171 <xi:include href="standard-options.xml" xpointer="version" />
172 </variablelist>
173 </refsect1>
174
175 <refsect1>
176 <title>User Record Properties</title>
177
178 <para>The following options control various properties of the user records/home directories that
179 <filename>systemd-homed.service</filename> manages. These switches may be used in conjunction with the
180 <command>create</command> and <command>update</command> commands for configuring various aspects of the
181 home directory and the user account:</para>
182
183 <variablelist>
184
185 <varlistentry>
186 <term><option>--real-name=</option><replaceable>NAME</replaceable></term>
187 <term><option>-c</option> <replaceable>NAME</replaceable></term>
188
189 <listitem><para>The real name for the user. This corresponds with the GECOS field on classic UNIX NSS
190 records.</para></listitem>
191 </varlistentry>
192
193 <varlistentry>
194 <term><option>--realm=</option><replaceable>REALM</replaceable></term>
195
196 <listitem><para>The realm for the user. The realm associates a user with a specific organization or
197 installation, and allows distuingishing users of the same name defined in different contexts. The
198 realm can be any string that also qualifies as valid DNS domain name, and it is recommended to use
199 the organization's or installation's domain name for this purpose, but this is not enforced nor
200 required. On each system only a single user of the same name may exist, and if a user with the same
201 name and realm is seen it is assumed to refer to the same user while a user with the same name but
202 different realm is considered a different user. Note that this means that two users sharing the same
203 name but with distinct realms are not allowed on the same system. Assigning a realm to a user is
204 optional.</para></listitem>
205 </varlistentry>
206
207 <varlistentry>
208 <term><option>--email-address=</option><replaceable>EMAIL</replaceable></term>
209
210 <listitem><para>Takes an electronic mail address to associate with the user. On log-in the
211 <varname>$EMAIL</varname> environment variable is initialized from this value.</para></listitem>
212 </varlistentry>
213
214 <varlistentry>
215 <term><option>--location=</option><replaceable>TEXT</replaceable></term>
216
217 <listitem><para>Takes location specification for this user. This is free-form text, which might or
218 might not be usable by geo-location applications. Example: <option>--location="Berlin,
219 Germany"</option> or <option>--location="Basement, Room 3a"</option></para></listitem>
220 </varlistentry>
221
222 <varlistentry>
223 <term><option>--icon-name=</option><replaceable>ICON</replaceable></term>
224
225 <listitem><para>Takes an icon name to associate with the user, following the scheme defined by the <ulink
226 url="https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon Naming
227 Specification</ulink>.</para></listitem>
228 </varlistentry>
229
230 <varlistentry>
231 <term><option>--home-dir=</option><replaceable>PATH</replaceable></term>
232 <term><option>-d</option><replaceable>PATH</replaceable></term>
233
234 <listitem><para>Takes a path to use as home directory for the user. Note that this is the directory
235 the user's home directory is mounted to while the user is logged in. This is not where the user's
236 data is actually stored, see <option>--image-path=</option> for that. If not specified defaults to
237 <filename>/home/$USER</filename>.</para></listitem>
238 </varlistentry>
239
240 <varlistentry>
241 <term><option>--uid=</option><replaceable>UID</replaceable></term>
242
243 <listitem><para>Takes a preferred numeric UNIX UID to assign this user. If a user is to be created
244 with the specified UID and it is already taken by a different user on the local system then creation
245 of the home directory is refused. Note though, if after creating the home directory it is used on a
246 different system and the configured UID is taken by another user there, then
247 <command>systemd-homed</command> may assign the user a different UID on that system. The specified
248 UID must be outside of the system user range. It is recommended to use the 60001…60513 UID range for
249 this purpose. If not specified the UID is automatically picked. When logging in and the home
250 directory is found to be owned by a UID not matching the user's assigned one the home directory and
251 all files and directories inside it will have their ownership changed automatically before login
252 completes.</para>
253
254 <para>Note that users managed by <command>systemd-homed</command> always have a matching group
255 associated with the same name as well as a GID matching the UID of the user. Thus, configuring the
256 GID separately is not permitted.</para></listitem>
257 </varlistentry>
258
259 <varlistentry>
260 <term><option>--member-of=</option><replaceable>GROUP</replaceable></term>
261 <term><option>-G</option> <replaceable>GROUP</replaceable></term>
262
263 <listitem><para>Takes a comma-separated list of auxiliary UNIX groups this user shall belong
264 to. Example: <option>--member-of=wheel</option> to provide the user with administrator
265 privileges. Note that <command>systemd-homed</command> does not manage any groups besides a group
266 matching the user in name and numeric UID/GID. Thus any groups listed here must be registered
267 independently, for example with <citerefentry
268 project='man-pages'><refentrytitle>groupadd</refentrytitle><manvolnum>8</manvolnum></citerefentry>. If
269 non-existant groups that are listed there are ignored. This option may be used more than once, in
270 which case all specified group lists are combined.</para></listitem>
271 </varlistentry>
272
273 <varlistentry>
274 <term><option>--skel=</option><replaceable>PATH</replaceable></term>
275
276 <listitem><para>Takes a file system path to a directory. Specifies the skeleton directory to
277 initialize the home directory with. All files and directories in the specified are copied into any
278 newly create home directory. If not specified defaults to
279 <filename>/etc/skel/</filename>.</para></listitem>
280 </varlistentry>
281
282 <varlistentry>
283 <term><option>--shell=</option><replaceable>SHELL</replaceable></term>
284
285 <listitem><para>Takes a file system path. Specifies the shell binary to execute on terminal
286 logins. If not specified defaults to <filename>/bin/bash</filename>.</para></listitem>
287 </varlistentry>
288
289 <varlistentry>
290 <term><option>--setenv=</option><replaceable>VARIABLE</replaceable>=<replaceable>VALUE</replaceable></term>
291
292 <listitem><para>Takes an environment variable assignment to set for all user processes. Note that a
293 number of other settings also result in environment variables to be set for the user, including
294 <option>--email=</option>, <option>--timezone=</option> and <option>--language=</option>. May be used
295 multiple times to set multiple environment variables.</para></listitem>
296 </varlistentry>
297
298 <varlistentry>
299 <term><option>--timezone=</option><replaceable>TIMEZONE</replaceable></term>
300
301 <listitem><para>Takes a timezone specification as string that sets the timezone for the specified
302 user. Expects a `tzdata` location string. When the user logs in the <varname>$TZ</varname>
303 environment variable is initialized from this setting. Example:
304 <option>--timezone=Europe/Amsterdam</option> will result in the environment variable
305 <literal>TZ=:Europe/Amsterdam</literal>.</para></listitem>
306 </varlistentry>
307
308 <varlistentry>
309 <term><option>--language=</option><replaceable>LANG</replaceable></term>
310
311 <listitem><para>Takes a specifier indicating the preferred language of the user. The
312 <varname>$LANG</varname> environment variable is initialized from this value on login, and thus a
313 value suitable for this environment variable is accepted here, for example
314 <option>--language=de_DE.UTF8</option></para></listitem>
315 </varlistentry>
316
317 <varlistentry>
318 <term><option>--ssh-authorized-keys=</option><replaceable>KEYS</replaceable></term>
319 <listitem><para>Either takes a SSH authorized key line to associate with the user record or a
320 <literal>@</literal> character followed by a path to a file to read one or more such lines from. SSH
321 keys configured this way are made available to SSH to permit access to this home directory and user
322 record. This option may be used more than once to configure multiple SSH keys.</para></listitem>
323 </varlistentry>
324
325 <varlistentry>
326 <term><option>--pkcs11-token-uri=</option><replaceable>URI</replaceable></term>
327 <listitem><para>Takes an RFC 7512 PKCS#11 URI referencing a security token (e.g. YubiKey or PIV
328 smartcard) that shall be able to unlock the user account. The security token URI should reference a
329 security token with exactly one pair of X.509 certificate and private key. A random secret key is
330 then generated, encrypted with the public key of the X.509 certificate, and stored as part of the
331 user record. At login time it is decrypted with the PKCS#11 module and then used to unlock the
332 account and associated resources. See below for an example how to set up authentication with security
333 token.</para></listitem>
334 </varlistentry>
335
336 <varlistentry>
337 <term><option>--locked=</option><replaceable>BOOLEAN</replaceable></term>
338
339 <listitem><para>Takes a boolean argument. Specifies whether this user account shall be locked. If
340 true logins into this account are prohibited, if false (the default) they are permitted (of course,
341 only if authorization otherwise succeeds).</para></listitem>
342 </varlistentry>
343
344 <varlistentry>
345 <term><option>--not-before=</option><replaceable>TIMESTAMP</replaceable></term>
346 <term><option>--not-after=</option><replaceable>TIMESTAMP</replaceable></term>
347
348 <listitem><para>These options take a timestamp string, in the format documented in
349 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> and
350 configures points in time before and after logins into this account are not
351 permitted.</para></listitem>
352 </varlistentry>
353
354 <varlistentry>
355 <term><option>--rate-limit-interval=</option><replaceable>SECS</replaceable></term>
356 <term><option>--rate-limit-burst=</option><replaceable>NUMBER</replaceable></term>
357
358 <listitem><para>Configures a rate limit on authentication attempts for this user. If the user
359 attempts to authenticate more often than the specified number, on a specific system, within the
360 specified time interval authentication is refused until the time interval passes. Defaults to 10
361 times per 1min.</para></listitem>
362 </varlistentry>
363
364 <varlistentry>
365 <term><option>--password-hint=</option><replaceable>TEXT</replaceable></term>
366
367 <listitem><para>Takes a password hint to store alongside the user record. This string is stored
368 accessible only to privileged users and the user itself and may not be queried by other users.
369 Example: <option>--password-hint="My first pet's name"</option></para></listitem>
370 </varlistentry>
371
372 <varlistentry>
373 <term><option>--enforce-password-policy=</option><replaceable>BOOL</replaceable></term>
374 <term><option>-P</option></term>
375
376 <listitem><para>Takes a boolean argument. Configures whether to enforce the system's password policy
377 for this user, regarding quality and strength of selected passwords. Defaults to
378 on. <option>-P</option> is short for
379 <option>---enforce-password-policy=no</option>.</para></listitem>
380 </varlistentry>
381
382 <varlistentry>
383 <term><option>--password-change-now=</option><replaceable>BOOL</replaceable></term>
384
385 <listitem><para>Takes a boolean argument. If true the user is asked to change their password on next
386 login.</para></listitem>
387 </varlistentry>
388
389 <varlistentry>
390 <term><option>--password-change-min=</option><replaceable>TIME</replaceable></term>
391 <term><option>--password-change-max=</option><replaceable>TIME</replaceable></term>
392 <term><option>--password-change-warn=</option><replaceable>TIME</replaceable></term>
393 <term><option>--password-change-inactive=</option><replaceable>TIME</replaceable></term>
394
395 <listitem><para>Each of these options takes a time span specification as argument (in the syntax
396 documented in
397 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>5</manvolnum></citerefentry>) and
398 configure various aspects of the user's password expiration policy. Specifically,
399 <option>--password-change-min=</option> configures how much time has to pass after changing the
400 password of the user until the password may be changed again. If the user tries to change their
401 password before this time passes the attempt is refused. <option>--password-change-max=</option>
402 configures how much time has to pass after the the password is changed until the password expires and
403 needs to be changed again. After this time passes any attempts to log in may only proceed after the
404 password is changed. <option>--password-change-warn=</option> specifies how much earlier than then
405 the time configured with <option>--password-change-max=</option> the user is warned at login to
406 change their password as it will expire soon. Finally <option>--password-change-inactive=</option>
407 configures the time which has to pass after the password as expired until the user is not permitted
408 to log in or change the password anymore. Note that these options only apply to password
409 authentication, and do not apply to other forms of authentication, for example PKCS#11-based security
410 token authentication.</para></listitem>
411 </varlistentry>
412
413 <varlistentry>
414 <term><option>--disk-size=</option><replaceable>BYTES</replaceable></term>
415 <listitem><para>Either takes a size in bytes as argument (possibly using the usual K, M, G, …
416 suffixes for 1024 base values), or a percentage value and configures the disk space to assign to the
417 user. If a percentage value is specified (i.e. the argument suffixed with <literal>%</literal>) it is
418 taken relative to the available disk space of the backing file system. If the LUKS2 backend is used
419 this configures the size of the loopback file and file system contained therein. For the other
420 storage backends configures disk quota using the filesystem's native quota logic, if available. If
421 not specified, defaults to 85% of the available disk space for the LUKS2 backend and to no quota for
422 the others.</para></listitem>
423 </varlistentry>
424
425 <varlistentry>
426 <term><option>--access-mode=</option><replaceable>MODE</replaceable></term>
427
428 <listitem><para>Takes a UNIX file access mode written in octal. Configures the access mode of the
429 home directory itself. Note that this is only used when the directory is first created, and the user
430 may change this any time afterwards. Example:
431 <option>--access-mode=0700</option></para></listitem>
432 </varlistentry>
433
434 <varlistentry>
435 <term><option>--umask=</option><replaceable>MASK</replaceable></term>
436
437 <listitem><para>Takes the access mode mask (in octal syntax) to apply to newly created files and
438 directories of the user ("umask"). If set this controls the initial umask set for all login sessions of
439 the user, possibly overriding the system's defaults.</para></listitem>
440 </varlistentry>
441
442 <varlistentry>
443 <term><option>--nice=</option><replaceable>NICE</replaceable></term>
444
445 <listitem><para>Takes the numeric scheduling priority ("nice level") to apply to the processes of the user at login
446 time. Takes a numeric value in the range -20 (highest priority) to 19 (lowest priority).</para></listitem>
447 </varlistentry>
448
449 <varlistentry>
450 <term><option>--rlimit=</option><replaceable>LIMIT</replaceable>=<replaceable>VALUE</replaceable><optional>:<replaceable>VALUE</replaceable></optional></term>
451
452 <listitem><para>Allows configuration of resource limits for processes of this user, see <citerefentry
453 project='man-pages'><refentrytitle>getrlimit</refentrytitle><manvolnum>2</manvolnum></citerefentry>
454 for details. Takes a resource limit name (e.g. <literal>LIMIT_NOFILE</literal>) followed by an equal
455 sign, followed by a numeric limit. Optionally, separated by colon a second numeric limit may be
456 specified. If two are specified this refers to the soft and hard limits, respectively. If only one
457 limit is specified the setting sets both limits in one.</para></listitem>
458 </varlistentry>
459
460 <varlistentry>
461 <term><option>--tasks-max=</option><replaceable>TASKS</replaceable></term>
462
463 <listitem><para>Takes a non-zero unsigned integer as argument. Configures the maximum numer of tasks
464 (i.e. processes and threads) the user may have at any given time. This limit applies to all tasks
465 forked off the user's sessions, even if they change user identity via <citerefentry
466 project='man-pages'><refentrytitle>su</refentrytitle><manvolnum>1</manvolnum></citerefentry> or a
467 similar tool. Use <option>--rlimit=LIMIT_NPROC=</option> to place a limit on the tasks actually
468 running under the UID of the user, thus excluding any child processes that might have changed user
469 identity. This controls the <varname>TasksMax=</varname> settting of the per-user systemd slice unit
470 <filename>user-$UID.slice</filename>. See
471 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
472 for further details.</para></listitem>
473 </varlistentry>
474
475 <varlistentry>
476 <term><option>--memory-high=</option><replaceable>BYTES</replaceable></term>
477 <term><option>--memory-max=</option><replaceable>BYTES</replaceable></term>
478
479 <listitem><para>Set a limit on the memory a user may take up on a system at any given time in bytes
480 (the usual K, M, G, … suffixes are supported, to the base of 1024). This includes all memory used by
481 the user itself and all processes they forked off that changed user credentials. This controls the
482 <varname>MemoryHigh=</varname> and <varname>MemoryMax=</varname> settings of the per-user systemd
483 slice unit <filename>user-$UID.slice</filename>. See
484 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
485 for further details.</para></listitem>
486 </varlistentry>
487
488 <varlistentry>
489 <term><option>--cpu-weight=</option><replaceable>WEIGHT</replaceable></term>
490 <term><option>--io-weight=</option><replaceable>WEIGHT</replaceable></term>
491
492 <listitem><para>Set a CPU and IO scheduling weights of the processes of the user, including those of
493 processes forked off by the user that changed user credentials. Takes a numeric value in the range
494 1…10000. This controls the <varname>CPUWeight=</varname> and <varname>IOWeight=</varname> settings of
495 the per-user systemd slice unit <filename>user-$UID.slice</filename>. See
496 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
497 for further details.</para></listitem>
498 </varlistentry>
499
500 <varlistentry>
501 <term><option>--storage=</option><replaceable>STORAGE</replaceable></term>
502
503 <listitem><para>Selects the storage mechanism to use for this home directory. Takes one of
504 <literal>luks</literal>, <literal>fscrypt</literal>, <literal>directory</literal>,
505 <literal>subvolume</literal>, <literal>cifs</literal>. For details about these mechanisms, see
506 above. If a new home directory is created and the storage type is not specifically specified defaults
507 to <literal>luks</literal> if supported, <literal>subvolume</literal> as first fallback if supported,
508 and <literal>directory</literal> if not.</para></listitem>
509 </varlistentry>
510
511 <varlistentry>
512 <term><option>--image-path=</option><replaceable>PATH</replaceable></term>
513
514 <listitem><para>Takes a file system path. Configures where to place the user's home directory. When
515 LUKS2 storage is used refers to the path to the loopback file, otherwise to the path to the home
516 directory. When unspecified defaults to <filename>/home/$USER.home</filename> when LUKS storage is
517 used and <filename>/home/$USER.homedir</filename> for the other storage mechanisms. Not defined for
518 the <literal>cifs</literal> storage mechanism. To use LUKS2 storage on a regular block device (for
519 example a USB stick) pass the path to the block device here.</para></listitem>
520 </varlistentry>
521
522 <varlistentry>
523 <term><option>--fs-type=</option><replaceable>TYPE</replaceable></term>
524
525 <listitem><para>When LUKS2 storage is used configures the file system type to use inside the home
526 directory LUKS2 container. One of <literal>ext4</literal>, <literal>xfs</literal>,
527 <literal>btrfs</literal>. If not specified defaults to <literal>ext4</literal>. Note that
528 <literal>xfs</literal> is not recommended as its support for file system resizing is too
529 limited.</para></listitem>
530 </varlistentry>
531
532 <varlistentry>
533 <term><option>--luks-discard=</option><replaceable>BOOL</replaceable></term>
534
535 <listitem><para>When LUKS2 storage is used configures whether to enable the
536 <literal>discard</literal> feature of the file system. If enabled the file system on top of the LUKS2
537 volume will report empty block information to LUKS2 and the loopback file below, ensuring that empty
538 space in the home directory is returned to the backing file system below the LUKS2 volume, resulting
539 in a "sparse" loopback file. This option mostly defaults to off, since this permits over-committing
540 home directories which results in I/O errors if the underlying file system runs full while the upper
541 file system wants to allocate a block. Such I/O errors are generally not handled well by file systems
542 nor applications. When LUKS2 storage is used on top of regular block devices (instead of on top a
543 loopback file) the discard logic defaults to on.</para></listitem>
544 </varlistentry>
545
546 <varlistentry>
547 <term><option>--luks-cipher=</option><replaceable>CIPHER</replaceable></term>
548 <term><option>--luks-cipher-mode=</option><replaceable>MODE</replaceable></term>
549 <term><option>--luks-volume-key-size=</option><replaceable>BITS</replaceable></term>
550 <term><option>--luks-pbkdf-type=</option><replaceable>TYPE</replaceable></term>
551 <term><option>--luks-pbkdf-hash-algorithm=</option><replaceable>ALGORITHM</replaceable></term>
552 <term><option>--luks-pbkdf-time-cost=</option><replaceable>SECONDS</replaceable></term>
553 <term><option>--luks-pbkdf-memory-cost=</option><replaceable>BYTES</replaceable></term>
554 <term><option>--luks-pbkdf-parallel-threads=</option><replaceable>THREADS</replaceable></term>
555
556 <listitem><para>Configures various cryptographic parameters for the LUKS2 storage mechanism. See
557 <citerefentry
558 project='man-pages'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
559 for details on the specific attributes.</para></listitem>
560 </varlistentry>
561
562 <varlistentry>
563 <term><option>--nosuid=</option><replaceable>BOOL</replaceable></term>
564 <term><option>--nodev=</option><replaceable>BOOL</replaceable></term>
565 <term><option>--noexec=</option><replaceable>BOOL</replaceable></term>
566
567 <listitem><para>Configures the <literal>nosuid</literal>, <literal>nodev</literal> and
568 <literal>noexec</literal> mount options for the home directories. By default <literal>nodev</literal>
569 and <literal>nosuid</literal> are on, while <literal>noexec</literal> is off. For details about these
570 mount options see <citerefentry
571 project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para></listitem>
572 </varlistentry>
573
574 <varlistentry>
575 <term><option>--cifs-domain=</option><replaceable>DOMAIN</replaceable></term>
576 <term><option>--cifs-user-name=</option><replaceable>USER</replaceable></term>
577 <term><option>--cifs-service=</option><replaceable>SERVICE</replaceable></term>
578
579 <listitem><para>Configures the Windows File Sharing (CIFS) domain and user to associate with the home
580 directory/user account, as well as the file share ("service") to mount as directory. The latter is used when
581 <literal>cifs</literal> storage is selected.</para></listitem>
582 </varlistentry>
583
584 <varlistentry>
585 <term><option>--stop-delay=</option><replaceable>SECS</replaceable></term>
586
587 <listitem><para>Configures the time the per-user service manager shall continue to run after the all
588 sessions of the user ended. The default is configured in
589 <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> (for
590 home directories of LUKS2 storage located on removable media this defaults to 0 though). A longer
591 time makes sure quick, repetitive logins are more efficient as the user's service manager doesn't
592 have to be started every time.</para></listitem>
593 </varlistentry>
594
595 <varlistentry>
596 <term><option>--kill-processes=</option><replaceable>BOOL</replaceable></term>
597
598 <listitem><para>Configures whether to kill all processes of the user on logout. The default is
599 configured in
600 <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para></listitem>
601 </varlistentry>
602
603 <varlistentry>
604 <term><option>--auto-login=</option><replaceable>BOOL</replaceable></term>
605
606 <listitem><para>Takes a boolean argument. Configures whether the graphical UI of the system should
607 automatically log this user in if possible. Defaults to off. If less or more than one user is marked
608 this way automatic login is disabled.</para></listitem>
609 </varlistentry>
610 </variablelist>
611 </refsect1>
612
613 <refsect1>
614 <title>Commands</title>
615
616 <para>The following commands are understood:</para>
617
618 <variablelist>
619
620 <varlistentry>
621 <term><command>list</command></term>
622
623 <listitem><para>List all home directories (along with brief details) currently managed by
624 <filename>systemd-homed.service</filename>. This command is also executed if none is specified on the
625 command line. (Note that the list of users shown by this command does not include users managed by
626 other subsystems, such as system users or any traditional users listed in
627 <filename>/etc/passwd</filename>.)</para></listitem>
628 </varlistentry>
629
630 <varlistentry>
631 <term><command>activate</command> <replaceable>USER</replaceable> [<replaceable>USER…</replaceable>]</term>
632
633 <listitem><para>Activate one or more home directories. The home directories of each listed user will
634 be activated and made available under their mount points (typically in
635 <filename>/home/$USER</filename>). Note that any home activated this way stays active indefinitely,
636 until it is explicitly deactivated again (with <command>deactivate</command>, see below), or the user
637 logs in and out again and it thus is deactivated due to the automatic deactivation-on-logout
638 logic.</para>
639
640 <para>Activation of a home directory involves various operations that depend on the selected storage
641 mechanism. If the LUKS2 mechanism is used, this generally involves: inquiring the user for a
642 password, setting up a loopback device, validating and activating the LUKS2 volume, checking the file
643 system, mounting the file system, and potentiatlly changing the ownership of all included files to
644 the correct UID/GID.</para></listitem>
645 </varlistentry>
646
647 <varlistentry>
648 <term><command>deactivate</command> <replaceable>USER</replaceable> [<replaceable>USER…</replaceable>]</term>
649
650 <listitem><para>Deactivate one or more home directories. This undoes the effect of
651 <command>activate</command>.</para></listitem>
652 </varlistentry>
653
654 <varlistentry>
655 <term><command>inspect</command> <replaceable>USER</replaceable> [<replaceable>USER…</replaceable>]</term>
656
657 <listitem><para>Show various details about the specified home directories. This shows various
658 information about the home directory and its user account, including runtime data such as current
659 state, disk use and similar. Combine with <option>--json=</option> to show the detailed JSON user
660 record instead, possibly combined with <option>--export-format=</option> to suppress certain aspects
661 of the output.</para></listitem>
662 </varlistentry>
663
664 <varlistentry>
665 <term><command>authenticate</command> <replaceable>USER</replaceable> [<replaceable>USER…</replaceable>]</term>
666
667 <listitem><para>Validate authentication credentials of a home directory. This queries the caller for
668 a password (or similar) and checks that it correctly unlocks the home directory. This leaves the home
669 directory in the state it is in, i.e. it leaves the home directory in inactive state if it was
670 inactive before, and in active state if it was active before.</para></listitem>
671 </varlistentry>
672
673 <varlistentry>
674 <term><command>create</command> <replaceable>USER</replaceable></term>
675 <term><command>create</command> <option>--identity=</option><replaceable>PATH</replaceable> <optional><replaceable>USER</replaceable></optional></term>
676
677 <listitem><para>Create a new home directory/user account of the specified name. Use the various
678 user record property options (as documented above) to control various aspects of the home directory
679 and its user accounts.</para></listitem>
680 </varlistentry>
681
682 <varlistentry>
683 <term><command>remove</command> <replaceable>USER</replaceable></term>
684
685 <listitem><para>Remove a home directory/user account. This will remove both the home directory's user
686 record and the home directory itself, and thus delete all files and directories owned by the
687 user.</para></listitem>
688 </varlistentry>
689
690 <varlistentry>
691 <term><command>update</command> <replaceable>USER</replaceable></term>
692 <term><command>update</command> <option>--identity=</option><replaceable>PATH</replaceable> <optional><replaceable>USER</replaceable></optional></term>
693
694 <listitem><para>Update a home directory/user account. Use the various user record property options
695 (as documented above) to make changes to the account, or alternatively provide a full, updated JSON
696 user record via the <option>--identity=</option> option.</para>
697
698 <para>Note that changes to user records not signed by a cryptographic private key available locally
699 are not permitted, unless <option>--identity=</option> is used with a user record that is already
700 correctly signed by a recognized private key.</para></listitem>
701 </varlistentry>
702
703 <varlistentry>
704 <term><command>passwd</command> <replaceable>USER</replaceable></term>
705
706 <listitem><para>Change the password of the specified home direcory/user account.</para></listitem>
707 </varlistentry>
708
709 <varlistentry>
710 <term><command>resize</command> <replaceable>USER</replaceable> <replaceable>BYTES</replaceable></term>
711
712 <listitem><para>Change the disk space assigned to the specified home directory. If the LUKS2 storage
713 mechanism is used this will automatically resize the loopback file and the file system contained
714 within. Note that if <literal>ext4</literal> is used inside of the LUKS2 volume, it is necessary to
715 deactivate the home directory before shrinking it (i.e the user has to log out). Growing can be done
716 while the home directory is active. If <literal>xfs</literal> is used inside of the LUKS2 volume the
717 home directory may not be shrunk whatsoever. On all three of <literal>ext4</literal>,
718 <literal>xfs</literal> and <literal>btrfs</literal> the home directory may be grown while the user is
719 logged in, and on the latter also shrunk while the user is logged in. If the
720 <literal>subvolume</literal>, <literal>directory</literal>, <literal>fscrypt</literal> storage
721 mechanisms are used, resizing will change file system quota.</para></listitem>
722 </varlistentry>
723
724 <varlistentry>
725 <term><command>lock</command> <replaceable>USER</replaceable></term>
726
727 <listitem><para>Temporarily suspend access to the user's home directory and remove any associated
728 cryptographic keys from memory. Any attempts to access the user's home directory will stall until the
729 home directory is unlocked again (i.e. re-authenticated). This functionality is primarily intended to
730 be used during system suspend to make sure the user's data cannot be accessed until the user
731 re-authenticates on resume. This operation is only defined for home directories that use the LUKS2
732 storage mechanism.</para></listitem>
733 </varlistentry>
734
735 <varlistentry>
736 <term><command>unlock</command> <replaceable>USER</replaceable></term>
737
738 <listitem><para>Resume access to the user's home directory again, undoing the effect of
739 <command>lock</command> above. This requires authentication of the user, as the cryptographic keys
740 required for access to the home directory need to be reacquired.</para></listitem>
741 </varlistentry>
742
743 <varlistentry>
744 <term><command>lock-all</command></term>
745
746 <listitem><para>Execute the <command>lock</command> command on all suitable home directories at
747 once. This operation is generally executed on system suspend (i.e. by <command>systemctl
748 suspend</command> and related commands), to ensure all active user's cryptographic keys for accessing
749 their home directories are removed from memory.</para></listitem>
750 </varlistentry>
751
752 <varlistentry>
753 <term><command>with</command> <replaceable>USER</replaceable> <replaceable>COMMAND…</replaceable></term>
754
755 <listitem><para>Activate the specified user's home directory, run the specified command (under the
756 caller's identity, not the specified user's) and deactivate the home directory afterwards again
757 (unless the user is logged in otherwise). This command is useful for running privileged backup
758 scripts and such, but requires authentication with the user's credentials in order to be able to
759 unlock the user's home directory.</para></listitem>
760 </varlistentry>
761 </variablelist>
762 </refsect1>
763
764 <refsect1>
765 <title>Exit status</title>
766
767 <para>On success, 0 is returned, a non-zero failure code otherwise.</para>
768 </refsect1>
769
770 <xi:include href="less-variables.xml" />
771
772 <refsect1>
773 <title>Examples</title>
774
775 <example>
776 <title>Create a user <literal>waldo</literal> in the administrator group <literal>wheel</literal>, and
777 assign 500 MiB disk space to them.</title>
778
779 <programlisting>homectl create waldo --real-name="Waldo McWaldo" -G wheel --disk-size=500M</programlisting>
780 </example>
781
782 <example>
783 <title>Create a user <literal>wally</literal> on a USB stick, and assign a maximum of 500 concurrent
784 tasks to them.</title>
785
786 <programlisting>homectl create wally --real-name="Wally McWally" --image-path=/dev/disk/by-id/usb-SanDisk_Ultra_Fit_476fff954b2b5c44-0:0 --tasks-max=500</programlisting>
787 </example>
788
789 <example>
790 <title>Change nice level of user <literal>odlaw</literal> to +5 and make sure the environment variable
791 <varname>$SOME</varname> is set to the string <literal>THING</literal> for them on login.</title>
792
793 <programlisting>homectl update odlaw --nice=5 --setenv=SOME=THING</programlisting>
794 </example>
795
796 <example>
797 <title>Set up authentication with a YubiKey security token:</title>
798
799 <programlisting># Clear the Yubikey from any old keys (careful!)
800ykman piv reset
801
802# Generate a new private/public key pair on the device, store the public key in 'pubkey.pem'.
803ykman piv generate-key -a RSA2048 9d pubkey.pem
804
805# Create a self-signed certificate from this public key, and store it on the device.
806ykman piv generate-certificate --subject "Knobelei" 9d pubkey.pem
807
808# We don't need the publibc key on disk anymore
809rm pubkey.pem
810
811# Check if the newly create key on the Yubikey shows up as token in PKCS#11. Have a look at the output, and
812# copy the resulting token URI to the clipboard.
813p11tool --list-tokens
814
815# Allow the security token referenced by the determined PKCS#11 URI to unlock the account of user
816# 'lafcadio'. (Replace the '…' by the URI from the clipboard.)
817homectl update lafcadio --pkcs11-token-uri=…</programlisting>
818 </example>
819 </refsect1>
820
821 <refsect1>
822 <title>See Also</title>
823 <para>
824 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
825 <citerefentry><refentrytitle>systemd-homed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
826 <citerefentry><refentrytitle>userdbctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
827 <citerefentry project='man-pages'><refentrytitle>useradd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
828 <citerefentry project='man-pages'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
829 </para>
830 </refsect1>
831
832</refentry>