git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/sshd: validate ssh configs during build
00a5222Maximilian Bosch
nixos/modules/services/networking/ssh/sshd.nix+10−1
@@ -4,6 +4,15 @@ with lib;
4
4
5let
5let
6
6
7+ sshconf = pkgs.runCommand "sshd.conf-validated" { nativeBuildInputs = [ cfgc.package ]; } ''
8+ cat >$out <<EOL
9+ ${cfg.extraConfig}
10+ EOL
11+
12+ ssh-keygen -f mock-hostkey -N ""
13+ sshd -t -f $out -h mock-hostkey
14+ '';
15+
7 cfg = config.services.openssh;
16 cfg = config.services.openssh;
8 cfgc = config.programs.ssh;
17 cfgc = config.programs.ssh;
9
18
@@ -339,7 +348,7 @@ in
339
348
340 environment.etc = authKeysFiles //
349 environment.etc = authKeysFiles //
341 { "ssh/moduli".source = cfg.moduliFile;
350 { "ssh/moduli".source = cfg.moduliFile;
342− "ssh/sshd_config".text = cfg.extraConfig;
351+ "ssh/sshd_config".source = sshconf;
343 };
352 };
344
353
345 systemd =
354 systemd =