[systemd-devel] Restarting sshd
Alexander E. Patrakov
patrakov at gmail.com
Tue Jan 11 01:12:13 PST 2011
Hello.
I have sshd-related unit files from http://0pointer.de/public/systemd-units/
sshd.service has the following problem, which is a regression from a
traditional SysV setup and which is not present in sshd.socket +
sshd at .service. Yes, I know that the use of this service is discouraged.
The problem is that one can no longer safely restart sshd while
connected via ssh. If one attempts to do so via "systemctl restart
sshd.service", all ssh sessions become disconnected. Also, the service
cannot be reloaded except by sending SIGHUP to the sunning sshd manually.
So, I propose the following improved version of sshd.service, with the
ability to reload the service, with safety regarding "systemctl restart
sshd.service", and with protection against crashes:
[Unit]
Description=SSH Secure Shell Service
After=syslog.target
[Service]
ExecStart=/usr/sbin/sshd -D
KillMode=process
Restart=always
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
# Note that this is the service file for running a single SSH server for all
# incoming connections, suitable only for systems with a large amount of SSH
# traffic. In almost all other cases it is a better idea to use
sshd.socket +
# sshd at .service (i.e. the on-demand spawning version for one instance per
# connection).
--
Alexander E. Patrakov
More information about the systemd-devel
mailing list