From 86d299bc6ec739702c5c8d2aae3e2d6b2bb94b1e Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Fri, 22 May 2015 14:23:21 +0200 Subject: [PATCH] nixos: add config.services.openssh.moduliFile option so that users can replace the default file from OpenSSH The man page for ssh-keygen(1) has a section "MODULI GENERATION" that describes how to generate your own moduli file. The following script might also be helpful: | #! /usr/bin/env bash | | moduliFiles=() | | generateModuli() | { | ssh-keygen -G "moduli-$1.candidates" -b "$1" | ssh-keygen -T "moduli-$1" -f "moduli-$1.candidates" | rm "moduli-$1.candidates" | } | | for (( i=0 ; i <= 16 ; ++i )); do | let bitSize="2048 + i * 128" | generateModuli "$bitSize" & | moduliFiles+=( "moduli-$bitSize" ) | done | wait | | echo >moduli "# Time Type Tests Tries Size Generator Modulus" | cat >>moduli "${moduliFiles[@]}" | rm "${moduliFiles[@]}" Note that generating moduli takes a long time, i.e. several hours on a fast machine! This patch resolves https://github.com/NixOS/nixpkgs/pull/5870. --- nixos/modules/services/networking/ssh/sshd.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/ssh/sshd.nix b/nixos/modules/services/networking/ssh/sshd.nix index 6cc86b4e4b5a..14d516ddbb66 100644 --- a/nixos/modules/services/networking/ssh/sshd.nix +++ b/nixos/modules/services/networking/ssh/sshd.nix @@ -268,6 +268,16 @@ in }; }; + moduliFile = mkOption { + example = "services.openssh.moduliFile = /etc/my-local-ssh-moduli;"; + type = types.path; + description = '' + Path to moduli file to install in + /etc/ssh/moduli. If this option is unset, then + the moduli file shipped with OpenSSH will be used. + ''; + }; + }; users.extraUsers = mkOption { @@ -286,8 +296,10 @@ in description = "SSH privilege separation user"; }; + services.openssh.moduliFile = mkDefault "${cfgc.package}/etc/ssh/moduli"; + environment.etc = authKeysFiles ++ [ - { source = "${cfgc.package}/etc/ssh/moduli"; + { source = cfg.moduliFile; target = "ssh/moduli"; } { text = knownHostsText;