From 80b40fdf03411a26c0340f28636fe9b5e0afc73b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 31 Mar 2017 16:16:27 +0200 Subject: [PATCH] sshd.nix: Alternative fix for #19589 AFAICT, this issue only occurs when sshd is socket-activated. It turns out that the preStart script's stdout and stderr are connected to the socket, not just the main command's. So explicitly connect stderr to the journal and redirect stdout to stderr. --- nixos/modules/services/networking/ssh/sshd.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/modules/services/networking/ssh/sshd.nix b/nixos/modules/services/networking/ssh/sshd.nix index 7e43ab98674..42b50d0426a 100644 --- a/nixos/modules/services/networking/ssh/sshd.nix +++ b/nixos/modules/services/networking/ssh/sshd.nix @@ -253,6 +253,10 @@ in preStart = '' + # Make sure we don't write to stdout, since in case of + # socket activation, it goes to the remote side (#19589). + exec >&2 + mkdir -m 0755 -p /etc/ssh ${flip concatMapStrings cfg.hostKeys (k: '' @@ -270,6 +274,7 @@ in KillMode = "process"; } // (if cfg.startWhenNeeded then { StandardInput = "socket"; + StandardError = "journal"; } else { Restart = "always"; Type = "simple";