Bug 1032109

Summary: reboot/shutdown does not close the clients connection
Product: Red Hat Enterprise Linux 7 Reporter: Petr Lautrbach <plautrba>
Component: systemdAssignee: systemd-maint
Status: CLOSED DUPLICATE QA Contact: qe-baseos-daemons
Severity: urgent Docs Contact:
Priority: high    
Version: 7.0CC: amascari, fdanapfe, lnykryn, mgrepl, plautrba, systemd-maint-list, tmraz
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-25 16:13:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1050219    

Description Petr Lautrbach 2013-11-19 15:02:22 UTC
+++ 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.

Thanks

nathan

--- 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 
[Unit]
Description=kill all sshd sessions
Requires=mutil-user.target

[Service]
ExecStart=/usr/bin/killall sshd
Type=oneshot

[Install]
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.

Comment 1 Frank Danapfel 2014-02-21 16:41:25 UTC
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
            trap TERM

Maybe this helps to fix this for RHEL7 as well.

Comment 2 Lukáš Nykrýn 2014-02-25 16:13:46 UTC

*** This bug has been marked as a duplicate of bug 1047614 ***