Red Hat Bugzilla – Bug 1032109
reboot/shutdown does not close the clients connection
Last modified: 2014-02-25 11:13:46 EST
+++ This bug was initially created as a clone of Bug #1023788 +++
i assume it has something to do with systemd, however, on my F20 test-VM reboot/shutdown let hang the client for a long time with no way to kill the session with STRG+C and the only way to release the terminal is to have a different one for "kill -s SIGKILL" the ssh-client
--- Additional comment from Nathan Crubel on 2013-11-18 16:26:31 CET ---
I am seeing the same issue.
--- Additional comment from Petr Lautrbach on 2013-11-19 15:35:39 CET ---
I can reproduce this issue using network.service instead of NetworkManager.service. And it incidentally works with nm.service because nm doesn't shut a network interface down on stop. The problem with ssh session is that should be killed only on shutdown/reboot and they shouldn't be killed at sshd stop, network stop and so.
Following unit works for me as a workaround:
# cat /etc/systemd/system/sshd-shutdown.service
Description=kill all sshd sessions
WantedBy=shutdown.target reboot.target poweroff.target
--- Additional comment from Harald Reindl on 2013-11-19 15:41:32 CET ---
i know that they should not be killed and sshd restart/stop and network restart but that doe snot change the fact that it is a regression because on F18/F19 there is no problem
--- Additional comment from Petr Lautrbach on 2013-11-19 15:58:57 CET ---
sshd.service are same on f18 and f19. So, as you wrote, it's probably related to something else than openssh itself and I'm still looking for it. I started with the sshd-shutdown.service unit as it might be one of solutions how to workaround random future changes in the systemd or network services.
On RHEL6 this issue was apparently fixed by adding the following to the stop() function of /etc/init.d/sshd:
# if we are in halt or reboot runlevel kill all running sessions
# so the TCP connections are closed cleanly
if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then
trap '' TERM
killall $prog 2>/dev/null
Maybe this helps to fix this for RHEL7 as well.
*** This bug has been marked as a duplicate of bug 1047614 ***