From 03f13a49392b90cdc54d8ff057cef76bf0379913 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Wed, 26 Sep 2012 21:00:55 +0200 Subject: [PATCH] Tell sshd not to detach into the background. This makes it easier for systemd to track it and avoids race conditions such as this one: systemd[1]: PID file /run/sshd.pid not readable (yet?) after start. systemd[1]: Failed to start SSH Daemon. systemd[1]: Unit sshd.service entered failed state. systemd[1]: sshd.service holdoff time over, scheduling restart. systemd[1]: Stopping SSH Daemon... systemd[1]: Starting SSH Daemon... sshd[2315]: Server listening on 0.0.0.0 port 22. sshd[2315]: Server listening on :: port 22. sshd[2335]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use. sshd[2335]: error: Bind to port 22 on :: failed: Address already in use. sshd[2335]: fatal: Cannot bind any address. systemd[1]: Started SSH Daemon. --- modules/services/networking/ssh/sshd.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/services/networking/ssh/sshd.nix b/modules/services/networking/ssh/sshd.nix index 242129c355e..373b482f85c 100644 --- a/modules/services/networking/ssh/sshd.nix +++ b/modules/services/networking/ssh/sshd.nix @@ -351,10 +351,10 @@ in serviceConfig = '' ExecStart=\ - ${pkgs.openssh}/sbin/sshd -h ${cfg.hostKeyPath} \ + ${pkgs.openssh}/sbin/sshd -D -h ${cfg.hostKeyPath} \ -f ${pkgs.writeText "sshd_config" cfg.extraConfig} Restart=always - Type=forking + Type=simple KillMode=process PIDFile=/run/sshd.pid '';