sshd kill all sessions on deamon stop

Message ID 6d9b9a50-4479-422f-a370-540a59fa6959@brecht-schule.hamburg
State New
Headers
Series sshd kill all sessions on deamon stop |

Commit Message

Peer Dietzmann 24 Aug 2025, 6:25 a.m. UTC
Hi All,

I discovered, that while rebooting an IPFire instance via SSH my 
terminal keeps stuck after the broadcast message because IPFire isn't 
closing all active connection correctly. As it is annoying especially 
when using SSH in SSH connections because all connections have to be 
reopened manually, I thought of adding just one line to the init-script 
that closes all running sessions.

Best regards,

Peer
  

Comments

Michael Tremer 24 Aug 2025, 12:55 p.m. UTC | #1
Hello Peer,

Thank you for your email.

I understand what you want to achieve here, but I don’t quite unterstand why. Why would those sessions need to be closed?

Your patch would have some other consequences which I don’t think you intend. For example, if someone would install an update using a SSH console and if that update upgrades OpenSSH and restarts it abort the update. The process would terminate the updater and you would be left with an incomplete update.

I suppose what we could think about is to move terminating the SSH daemon before the network is being shut down. Would that fix your problem?

-Michael

> On 24 Aug 2025, at 07:25, Peer Dietzmann <dietzmann@brecht-schule.hamburg> wrote:
> 
> Hi All,
> 
> I discovered, that while rebooting an IPFire instance via SSH my terminal keeps stuck after the broadcast message because IPFire isn't closing all active connection correctly. As it is annoying especially when using SSH in SSH connections because all connections have to be reopened manually, I thought of adding just one line to the init-script that closes all running sessions.
> 
> Best regards,
> 
> Peer
> 
> 
> diff --git a/src/initscripts/system/sshd b/src/initscripts/system/sshd
> index e5a9931af..e69904c61 100644
> --- a/src/initscripts/system/sshd
> +++ b/src/initscripts/system/sshd
> @@ -50,6 +50,7 @@ case "$1" in
>      stop)
>          boot_mesg "Stopping SSH Server..."
>          killproc -p "/var/run/sshd.pid" /usr/sbin/sshd || true
> +        killall sshd-session
>          ;;
> 
>      reload)
> 
>
  

Patch

diff --git a/src/initscripts/system/sshd b/src/initscripts/system/sshd
index e5a9931af..e69904c61 100644
--- a/src/initscripts/system/sshd
+++ b/src/initscripts/system/sshd
@@ -50,6 +50,7 @@  case "$1" in
      stop)
          boot_mesg "Stopping SSH Server..."
          killproc -p "/var/run/sshd.pid" /usr/sbin/sshd || true
+        killall sshd-session
          ;;

      reload)