summary refs log tree commit diff
path: root/nixos/modules/system/boot/stage-1.nix
diff options
context:
space:
mode:
authorEmily <vcs@emily.moe>2020-03-14 18:29:08 +0000
committerEmily <vcs@emily.moe>2020-03-25 08:26:50 +0000
commitd930466b7728e5515991cb73c060fc3f32bdc001 (patch)
treefccf4df70689dbf469d9ebae5a88e410d282702a /nixos/modules/system/boot/stage-1.nix
parent01914e619f466d93d91ab6e563b17b9357f4a63a (diff)
downloadnixpkgs-d930466b7728e5515991cb73c060fc3f32bdc001.tar
nixpkgs-d930466b7728e5515991cb73c060fc3f32bdc001.tar.gz
nixpkgs-d930466b7728e5515991cb73c060fc3f32bdc001.tar.bz2
nixpkgs-d930466b7728e5515991cb73c060fc3f32bdc001.tar.lz
nixpkgs-d930466b7728e5515991cb73c060fc3f32bdc001.tar.xz
nixpkgs-d930466b7728e5515991cb73c060fc3f32bdc001.tar.zst
nixpkgs-d930466b7728e5515991cb73c060fc3f32bdc001.zip
nixos/initrd-ssh: switch from Dropbear to OpenSSH
Dropbear lags behind OpenSSH significantly in both support for modern
key formats like `ssh-ed25519`, let alone the recently-introduced
U2F/FIDO2-based `sk-ssh-ed25519@openssh.com` (as I found when I switched
my `authorizedKeys` over to it and promptly locked myself out of my
server's initrd SSH, breaking reboots), as well as security features
like multiprocess isolation. Using the same SSH daemon for stage-1 and
the main system ensures key formats will always remain compatible, as
well as more conveniently allowing the sharing of configuration and
host keys.

The main reason to use Dropbear over OpenSSH would be initrd space
concerns, but NixOS initrds are already large (17 MiB currently on my
server), and the size difference between the two isn't huge (the test's
initrd goes from 9.7 MiB to 12 MiB with this change). If the size is
still a problem, then it would be easy to shrink sshd down to a few
hundred kilobytes by using an initrd-specific build that uses musl and
disables things like Kerberos support.

This passes the test and works on my server, but more rigorous testing
and review from people who use initrd SSH would be appreciated!
Diffstat (limited to 'nixos/modules/system/boot/stage-1.nix')
-rw-r--r--nixos/modules/system/boot/stage-1.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix
index 93cd801ef80..9e3ee5cf0a3 100644
--- a/nixos/modules/system/boot/stage-1.nix
+++ b/nixos/modules/system/boot/stage-1.nix
@@ -142,7 +142,10 @@ let
              let source' = if source == null then dest else source; in
                ''
                   mkdir -p $(dirname "$out/secrets/${dest}")
-                  cp -a ${source'} "$out/secrets/${dest}"
+                  # Some programs (e.g. ssh) doesn't like secrets to be
+                  # symlinks, so we use `cp -L` here to match the
+                  # behaviour when secrets are natively supported.
+                  cp -Lr ${source'} "$out/secrets/${dest}"
                 ''
           ) config.boot.initrd.secrets))
        }