Edit: Nevermind, solved. I was able to ssh in from a different computer, login with the new account, zfs-rollback /persist/etc/nixos/configuration.nix
, and recreate the deleted user account. Crisis averted, wew
Hello, I just did a nixos-rebuild switch
and deleted my user account from /etc/passwd
. I’m still logged in, still have my home directory, but can’t rollback to the previous generation since my logged-in account is no longer in the passwd database (no sudo). Is there any way to undo this?
TLDR: In configuration.nix
users section, I added the name=
property, thinking it was just metadata similar to the description=
property, not realizing it was the actual account id.
The configuration.nix
change I made that caused this:
Original:
users = {
mutableUsers = false;
defaultUserShell = "/var/run/current-system/sw/bin/zsh";
users = {
root = {
# disable root login here, and also when installing nix by running `nixos-install --no-root-passwd`
# https://discourse.nixos.org/t/how-to-disable-root-user-account-in-configuration-nix/13235/3
hashedPassword = "!"; # disable root logins, nothing hashes to !
};
bgibson = {
isNormalUser = true;
description = "My Account";
passwordFile = "/persist/etc/users/bgibson";
extraGroups = [ "wheel" "networkmanager" ];
#openssh.authorizedKeys.keys = [ "${AUTHORIZED_SSH_KEY}" ];
};
};
};
New broken:
users = {
mutableUsers = false;
defaultUserShell = "/var/run/current-system/sw/bin/zsh";
users = {
root = {
# disable root login here, and also when installing nix by running `nixos-install --no-root-passwd`
# https://discourse.nixos.org/t/how-to-disable-root-user-account-in-configuration-nix/13235/3
hashedPassword = "!"; # disable root logins, nothing hashes to !
};
bgibson = {
isNormalUser = true;
name = "Byron Gibson"
description = "My Account";
passwordFile = "/persist/etc/users/bgibson";
extraGroups = [ "wheel" "networkmanager" ];
#openssh.authorizedKeys.keys = [ "${AUTHORIZED_SSH_KEY}" ];
};
};
};
That deleted my account bgibson
(uid=1001) and created a new one Byron Gibson
(uid=1003). Is there any way to revert this while I’m still logged in?
I’m running root on tmpfs, and everything else on ZFS, so this should be undo-able. However, without sudo I can’t do a zfs rollback
to a prior snapshot of /etc/nixos/configuration.nix
.
It occurs to me I can su into the new user account and use that account’s sudo ability to recreate my original account. But how do you su into an account with a space in the name? Edit: doesn’t look like su
works without my logged in userid existing in /etc/passwd.