2

Sometimes I need to change a parameter in the sshd_config file on a server I'm remotely connected to, and to apply the change, I need to restart the service.

What does it make my connection survive to this ?

06:23 $ sudo systemctl restart sshd.service
✔ ~/ansible-repository [master L|✚ 1…37]
06:23 $

1 Answer 1

2

From the man page:

sshd listens for connections from clients. It is normally started at boot from /etc/rc. It forks a new daemon for each incoming connection. The forked daemons handle key exchange, encryption, authentication, command execution, and data exchange.

So your sshd listens for connections but then forks a new process when a user connects to the server.

When you restart sshd you are only restarting the process that listens for new connections. All existing connections stay intact.

1
  • 2
    That's not a complete explanation. For starters: The systemd default for restarting a service is to attempt to kill all processes in the control group, which would kill all of those forked children. This answer does not explain this discrepancy. Nor, furthermore, does it account for the mode of running an SSH server that is pointed out in unix.stackexchange.com/a/507798/5132 .
    – JdeBP
    Commented Oct 20, 2020 at 7:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .