declared root password in nixos configuration.nix via hashedPassword. Did nixos-rebuild boot. Rebooted and logged in. Still the old root password persists, instead of the hashedPassword declared.
I’m using NixOS KDE. Maybe something is overriding the config?
My guess is some imperative operation still used by some program like KDE and ovverrides it ?
Use passwd
instead (imperative)
sudo su
passwd root
Security wise and depending on your use case, it’s recommended to avoid setting a password for root
user so noone can log as root
into your instance.
1 Like
It’s likely because you did not explicitly set users.mutableUsers = false;
.
If the option users.mutableUsers
is true, the password defined in one of the above password options will only be set when the user is created for the first time. After that, you are free to change the password with the ordinary user management commands.
(c.f. users.users.\<name\>.hashedPassword
documentation)
If set to true
, you are free to add new users and groups to the system with the ordinary useradd
and groupadd
commands. On system activation, the existing contents of the /etc/passwd
and /etc/group
files will be merged with the contents generated from the users.users
and users.groups
options. The initial password for a user will be set according to users.users
, but existing passwords will not be changed.
Warning
If set to false
, the contents of the user and group files will simply be replaced on system activation. This also holds for the user passwords; all changed passwords will be reset according to the users.users
configuration on activation.
(c.f. users.mutableUsers
documentation)
3 Likes