Created attachment 849588 [details] The url of the service file (since new accounts can't add urls in bug reports) The current systemd service file for sshd does not contain the restart=on-failure option to automatically restart ssh server if the service fails / crashes or gets killed, making the server unavailable to ssh. This is really problematic when the server is not physically accessible. So, please add the restart option to the service file.
restart=always is better I guess. on-failure only restarts on non 0 exit code and always restarts in all cases. The latter would be better for sshd.
Looked into this. `Restart=on-failure` seems like a sane default. This will cover non-zero exit code, "Unclean" signals, Timers, and Watchdogs. We shouldn't need to handle the remaining case "Zero exit code" here with `Restart=always`; If the process exits normally I feel like it should stay exited.
I am no expert and so I looked into other distributions. Debian uses Restart=on-failure Link: https://sources.debian.org/src/openssh/1%3A9.1p1-2/debian/systemd/ssh.service/ Fedora uses Restart=on-failure Link: https://src.fedoraproject.org/rpms/openssh/blob/rawhide/f/sshd.service Arch linux uses Restart=always Link: https://github.com/archlinux/svntogit-packages/blob/packages/openssh/trunk/sshd.service OpenSUSE uses Restart=on-failure Link: https://build.opensuse.org/package/view_file/network/openssh/sshd.service?expand=1
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f0469c1f161335aad3997e34f9cef0af0436a502 commit f0469c1f161335aad3997e34f9cef0af0436a502 Author: Matt Jolly <Matt.Jolly@footclan.ninja> AuthorDate: 2023-02-02 05:44:07 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2023-02-05 00:10:07 +0000 net-misc/openssh: update systemd units - Systemd unit file now sets: + OOMPolicy=continue + Restart=on-failure + RestartSec=42s - Removed `After=syslog.target` from sshd unit files - Remove obsolete substitutions Closes: https://bugs.gentoo.org/892784 Closes: https://github.com/gentoo/gentoo/pull/29386 Signed-off-by: Matt Jolly <Matt.Jolly@footclan.ninja> Signed-off-by: Mike Gilbert <floppym@gentoo.org> net-misc/openssh/files/sshd.service.1 | 15 +++++++++++++++ net-misc/openssh/files/sshd_at.service.1 | 8 ++++++++ ...enssh-9.2_p1.ebuild => openssh-9.2_p1-r1.ebuild} | 21 ++++++++++++--------- 3 files changed, 35 insertions(+), 9 deletions(-)