User management: Difference between revisions

Pigs (talk | contribs)
Create user management page
 
Pigs (talk | contribs)
add user to group section
 
(2 intermediate revisions by the same user not shown)
Line 11: Line 11:
User passwords can be defined declaratively by specifying a hashed password in the system configuration. To generate a password hash, run the following command and enter the desired password when prompted: <code>mkpasswd</code>
User passwords can be defined declaratively by specifying a hashed password in the system configuration. To generate a password hash, run the following command and enter the desired password when prompted: <code>mkpasswd</code>


The resulting hash can then be assigned to <code>hashedPassword</code>, <code>initialHashedPassword</code>, or <code>hashedPasswordFile</code> options within the user definition. For more information, refer to {{nixos:option|users.users.*.*hashedPassword}}. Example:
The resulting hash can then be assigned to {{nixos:option|users.users.*.*hashedPassword|hashedPassword, initialHashedPassword, or hashedPasswordFile}} options within the user definition. Example:


{{file|/etc/nixos/configuration.nix|nix|
{{file|/etc/nixos/configuration.nix|nix|
Line 24: Line 24:
== User Home Directories ==
== User Home Directories ==


By default, user home directories are created at <code>/home/<username></code> when {{nixos:option|users.users.*.isNormalUser}} is true.
By default, user home directories are created at <code>/home/<username></code> when {{nixos:option|users.users.*.isNormalUser|users.users.<name>.isNormalUser}} is true.


Custom home directories can be set via the <code>home</code> option:
Custom home directories can be set via the <code>home</code> option:
Line 33: Line 33:
{{main|Command Shell}}  
{{main|Command Shell}}  


Login shells can be customized by setting the {{nixos:option|users.users.*.shell}} option.
Login shells can be customized by setting the {{nixos:option|users.users.*.shell|users.users.<name>.shell}} option.


== User SSH Authorized Keys ==
== User SSH Authorized Keys ==
Line 39: Line 39:
{{main|SSH public key authentication#SSH server configuration}}
{{main|SSH public key authentication#SSH server configuration}}


SSH authentication can be customized by setting the {{nixos:option|users.users.*.openssh.authorizedKeys}} option.
SSH authentication can be customized by setting the {{nixos:option|users.users.*.openssh.authorizedKeys|users.users.<name>.openssh.authorizedKeys}} option.
 
== Adding User to a group ==
 
Users can be added to a group by setting the {{nixos:option|users.users.*.extraGroups|users.users.<name>.extraGroups}} option. For example:
 
{{file|/etc/nixos/configuration.nix|nix|
<nowiki>
  users.users.alice = {
    ...
    extraGroups = [ "wheel" "networkmanager" ];
  };
</nowiki>
}}


== Home Manager ==
== Home Manager ==


For additional user environment configuration, including management of dotfiles, shell settings, and user-specific packages, consider using [[Home Manager]].
For additional user environment configuration, including management of dotfiles, shell settings, and user-specific packages, consider using [[Home Manager]].
[[Category:Configuration]]
[[Category:NixOS Manual]]