Describe the bug
Nixos changed from Dropbear to OpenSSH in the initrd. While doing so it requires new keys and new options were add.
However following the instructions still fails to build.
To Reproduce
Steps to reproduce the behavior:
- I first generated a key at
/root/initrd-openssh-key and added the following to the configuration.nix:
hostKeys = [ "/root/initrd-openssh-key" ];
- Rebuilding failed with this error:
cp: cannot stat '/root/initrd-openssh-key': No such file or directory
- However that file exists:
ls -al /root/initrd-openssh-key
-rwxr-xr-x 1 root root 227 Apr 4 07:18 /root/initrd-openssh-key
- Then I followed the instructions from the module file https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/initrd-ssh.nix :
example = [
"/etc/secrets/initrd/ssh_host_rsa_key"
"/etc/secrets/initrd/ssh_host_ed25519_key"
];
[...]
<prompt># </prompt>ssh-keygen -t rsa -N "" -f /etc/secrets/initrd/ssh_host_rsa_key
<prompt># </prompt>ssh-keygen -t ed25519 -N "" -f /etc/secrets/initrd/ssh_host_ed_25519_key
So I created the /etc/secrets/initrd folder and run the two commands, which resulted in:
ls -al /etc/secrets/initrd/
total 35
drwxr-xr-x 2 root root 6 Apr 11 07:39 .
drwxr-xr-x 3 root root 3 Apr 11 07:39 ..
-rw------- 1 root root 399 Apr 11 07:39 ssh_host_ed_25519_key
-rw-r--r-- 1 root root 91 Apr 11 07:39 ssh_host_ed_25519_key.pub
-rw------- 1 root root 2590 Apr 11 07:39 ssh_host_rsa_key
-rw-r--r-- 1 root root 563 Apr 11 07:39 ssh_host_rsa_key.pub
- I then added the following to my configuration.nix nix:
boot.initrd.network = {
enable = true;
ssh = {
enable = true;
port = 2222;
# hostECDSAKey = /root/initrd-ssh-key;
hostKeys = [
"/etc/secrets/initrd/ssh_host_rsa_key"
"/etc/secrets/initrd/ssh_host_ed25519_key"
];
authorizedKeys = [ "${mySecrets.auth_ssh_key1}" "${mySecrets.auth_ssh_key2}" ];
};
postCommands = ''
echo "zfs load-key -a; killall zfs" >> /root.profile
'';
};
and rebuild again. This time it failed:
cp: cannot stat '/etc/secrets/initrd/ssh_host_ed25519_key': No such file or directory
builder for '/nix/store/pff2dr2i17mjsjavkg6icy5wfixjjlyb-extra-utils.drv' failed with exit code 1
cannot build derivation '/nix/store/i33w1h0asyc33yl1m5f1cl1wpif3xmf0-stage-1-init.sh.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/aqmbw803m7rb4k38lrvfj11zbs1pb81m-initrd-linux-5.4.30.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/zcqgphq575pzzjf7kf7dvcpj5v3zxbbg-nixos-system-subi-20.09pre220429.9b0d2f3fd15.drv': 1 dependencies couldn't be built
error: build of '/nix/store/zcqgphq575pzzjf7kf7dvcpj5v3zxbbg-nixos-system-subi-20.09pre220429.9b0d2f3fd15.drv' failed
Expected behavior
It should properly detect the file provided in the hostKeys.
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
- system:
"x86_64-linux"
- host os:
Linux 5.5.13, NixOS, 20.09pre218613.ae6bdcc5358 (Nightingale)
- multi-user?:
yes
- sandbox:
yes
- version:
nix-env (Nix) 2.3.3
- channels(hyper):
"nixos-19.09pre185402.5eac339829b"
- channels(root):
"nixos-20.09pre220429.9b0d2f3fd15"
- nixpkgs:
/nix/var/nix/profiles/per-user/root/channels/nixos
Maintainer information:
# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module: initrd-ssh.nix
Describe the bug
Nixos changed from Dropbear to OpenSSH in the initrd. While doing so it requires new keys and new options were add.
However following the instructions still fails to build.
To Reproduce
Steps to reproduce the behavior:
/root/initrd-openssh-keyand added the following to the configuration.nix:So I created the /etc/secrets/initrd folder and run the two commands, which resulted in:
and rebuild again. This time it failed:
Expected behavior
It should properly detect the file provided in the hostKeys.
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"and paste the result."x86_64-linux"Linux 5.5.13, NixOS, 20.09pre218613.ae6bdcc5358 (Nightingale)yesyesnix-env (Nix) 2.3.3"nixos-19.09pre185402.5eac339829b""nixos-20.09pre220429.9b0d2f3fd15"/nix/var/nix/profiles/per-user/root/channels/nixosMaintainer information: