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