about summary refs log tree commit diff
path: root/nixos/modules/services/networking/ssh
diff options
context:
space:
mode:
authorMichael Adler <therisen06@gmail.com>2022-08-08 23:10:59 +0200
committerMichael Adler <therisen06@gmail.com>2022-08-09 12:16:17 +0200
commitd8b356caafb34d454737a79bb0fc6076f3da0b5d (patch)
tree524ba656d5a466994ce911c3a0ffd6ac2fd00008 /nixos/modules/services/networking/ssh
parentb74d6cd93f924f87676869ebc152e23a11c58f54 (diff)
downloadnixlib-d8b356caafb34d454737a79bb0fc6076f3da0b5d.tar
nixlib-d8b356caafb34d454737a79bb0fc6076f3da0b5d.tar.gz
nixlib-d8b356caafb34d454737a79bb0fc6076f3da0b5d.tar.bz2
nixlib-d8b356caafb34d454737a79bb0fc6076f3da0b5d.tar.lz
nixlib-d8b356caafb34d454737a79bb0fc6076f3da0b5d.tar.xz
nixlib-d8b356caafb34d454737a79bb0fc6076f3da0b5d.tar.zst
nixlib-d8b356caafb34d454737a79bb0fc6076f3da0b5d.zip
fix: ssh-keygen fails if directory does not exist
Diffstat (limited to 'nixos/modules/services/networking/ssh')
-rw-r--r--nixos/modules/services/networking/ssh/sshd.nix3
1 files changed, 1 insertions, 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 ""} \