Как отключить пароль root в NixOS?

Вы избежали одного знака процента, а не другого:

$(($(date +\%u)%2))
               ^
              HERE

Все знаки процента в записи crontab должны быть экранированы, потому что % имеет там особое значение. Цитата из crontab (5 )man-страницы:

The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command,unless escaped with backslash (), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

Правда, этот абзац можно было бы сформулировать лучше.

Так и должно быть:

$(($(date +\%u)\%2))
2
23.07.2019, 13:15
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
0
27.01.2020, 22:24

Теги

Похожие вопросы