From d8b356caafb34d454737a79bb0fc6076f3da0b5d Mon Sep 17 00:00:00 2001 From: Michael Adler Date: Mon, 8 Aug 2022 23:10:59 +0200 Subject: [PATCH] fix: ssh-keygen fails if directory does not exist --- nixos/modules/services/networking/ssh/sshd.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/ssh/sshd.nix b/nixos/modules/services/networking/ssh/sshd.nix index 6da83eb7de10..00ec15c54bc1 100644 --- a/nixos/modules/services/networking/ssh/sshd.nix +++ b/nixos/modules/services/networking/ssh/sshd.nix @@ -435,13 +435,12 @@ in # socket activation, it goes to the remote side (#19589). exec >&2 - mkdir -m 0755 -p /etc/ssh - ${flip concatMapStrings cfg.hostKeys (k: '' if ! [ -s "${k.path}" ]; then if ! [ -h "${k.path}" ]; then rm -f "${k.path}" fi + mkdir -m 0755 -p "$(dirname '${k.path}')" ssh-keygen \ -t "${k.type}" \ ${if k ? bits then "-b ${toString k.bits}" else ""} \