NixOSでrootパスワードを無効にする方法は?

NixOSでrootパスワードを無効にする方法は?

私は、またはusers.users.root.hashedPassword = "*";同じものを設定しようとしました。sudo passwd -d root

user { 'root':
  password => '*',
  require  => Package[ruby-shadow],
}

存在する人形ただし、後で以前のパスワードを引き続きsudo nixos-rebuild switch使用できます。su -

ベストアンサー1

mutableUsers次のように設定する必要がありますfalseユーザーパスワード

users = {

 #normal users declaration here

  mutableUsers = false;

  extraUsers = {

    root = {
      hashedPassword = "*";
    };
     user = {
      hashedPassword = "user-password";
    }; 
   };
};

マンページ:man configuration.nix

   users.users.<name?>.hashedPassword
       Specifies the hashed password for the user. The options
       hashedPassword, password and passwordFile controls what password is
       set for the user.  hashedPassword overrides both password and
       passwordFile.  password overrides passwordFile. If none of these
       three options are set, no password is assigned to the user, and the
       user will not be able to do password logins. If the option
       users.mutableUsers is true, the password defined in one of the
       three 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. If users.mutableUsers is
       false, you cannot change user passwords, they will always be set
       according to the password options.

新しい世代をテストするためにラベルを設定できます(ラベル付きnoroot)。

nixos-rebuild switch -p noroot -I nixos-config=/etc/nixos/configuration.nix

おすすめ記事