Error on Ssh server in Debian 10 Buster

Had similar error here, it looks that sshd is failing to create /run/sshd directory while booting up, so managed here to do it via script, as follows:

Create a sshddir script with following content in /etc/init.d/:

#!/bin/sh

### BEGIN INIT INFO
# Provides:          sshddir
# Required-Start:    $all
# Required-Stop:     $network
# Should-Start:      $network
# Default-Start:     3 4 5
# Default-Stop:      0 1 2 6
# Short-Description: Sshd /run/sshd Directory
# Description:       Intended to create /run/sshd directory for Sshd.
### END INIT INFO

mkdir -p /run/sshd

chmod -R 755 /run/sshd

$ sudo chmod 755 /etc/init.d/sshddir

$ sudo update-rc.d sshddir defaults

That way, may reboot and access it.


Just create sshddir.service file in /etc/system/systemd/ with following contents:

[Unit]
Description=Run Sshd Directory Creator
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
ExecStart=/usr/bin/sshddir
ExecReload=/usr/bin/sshddir
Restart=always
RestartPreventExitStatus=255
Type=forking

[Install]
WantedBy=multi-user.target
Alias=sshddir.service

Then:

2a - $ sudo systemctl daemon-reload

2b - $ sudo systemctl enable sshddir

But is needed, first, remove SysVinit managed file:

1a - $ update-rc.d sshddir disable

1b - $ update-rc.d sshddir remove

Only then, reboot machine.

Looks like somehow systemd removes /run/sshd folder on boot up, generating error.

Tags:

Ssh

Debian

Sshd