Skip to content

Commit 43fa0fc

Browse files
committed
nixos-configuration-on-vm: show initialHashedPassword
Instead of showing people `initialPassword` and then telling them not to use it, just show `initialHashedPassword` directly.
1 parent 8061765 commit 43fa0fc

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

source/tutorials/nixos/nixos-configuration-on-vm.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ To be able to log in, add the following lines to the returned attribute set:
5252
};
5353
```
5454

55-
Additionally, you need to specify a password for this user.
56-
For the purpose of demonstration only, you specify an insecure, plain text password by adding the `initialPassword` option to the user configuration:
55+
Additionally, you need to specify a password for this user. You can generate a hashed password with `mkpasswd` and then add it as:
5756

5857
```nix
59-
initialPassword = "test";
58+
initialHashedPassword = "$y$j9T$1Cxi0roo3nE7GNTBz0NKs.$uGc0FJbwMhU2PgscNZlEmpMml1vShvbC6JSxdyM0is8";
6059
```
6160

6261
We add two lightweight programs as an example:
@@ -68,8 +67,8 @@ We add two lightweight programs as an example:
6867
];
6968
```
7069

71-
:::{warning}
72-
Do not use plain text passwords outside of this example unless you know what you are doing. See [`initialHashedPassword`](https://nixos.org/manual/nixos/stable/options.html#opt-users.extraUsers._name_.initialHashedPassword) or [`ssh.authorizedKeys`](https://nixos.org/manual/nixos/stable/options.html#opt-users.extraUsers._name_.openssh.authorizedKeys.keys) for more secure alternatives.
70+
:::{note}
71+
you can also use [`ssh.authorizedKeys`](https://nixos.org/manual/nixos/stable/options.html#opt-users.extraUsers._name_.openssh.authorizedKeys.keys) for passwordless login.
7372
:::
7473

7574
(sample-nixos-config)=
@@ -86,7 +85,7 @@ The complete `configuration.nix` file looks like this:
8685
users.users.alice = {
8786
isNormalUser = true;
8887
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
89-
initialPassword = "test";
88+
initialHashedPassword = "$y$j9T$1Cxi0roo3nE7GNTBz0NKs.$uGc0FJbwMhU2PgscNZlEmpMml1vShvbC6JSxdyM0is8";
9089
};
9190
9291
environment.systemPackages = with pkgs; [
@@ -231,7 +230,7 @@ The complete `configuration.nix` file looks like this:
231230
users.users.alice = {
232231
isNormalUser = true;
233232
extraGroups = [ "wheel" ];
234-
initialPassword = "test";
233+
initialHashedPassword = "$y$j9T$1Cxi0roo3nE7GNTBz0NKs.$uGc0FJbwMhU2PgscNZlEmpMml1vShvbC6JSxdyM0is8";
235234
};
236235
237236
system.stateVersion = "24.05";
@@ -286,7 +285,7 @@ Arguments to QEMU can also be added to the configuration file:
286285
users.users.alice = {
287286
isNormalUser = true;
288287
extraGroups = [ "wheel" ];
289-
initialPassword = "test";
288+
initialHashedPassword = "$y$j9T$1Cxi0roo3nE7GNTBz0NKs.$uGc0FJbwMhU2PgscNZlEmpMml1vShvbC6JSxdyM0is8";
290289
};
291290
292291
system.stateVersion = "24.05";

0 commit comments

Comments
 (0)