[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#751636: openssh-server: ssh sessions are not cleanly termined on shutdown/restart with systemd



Hi,

 

I had the same issue under Debian Wheezy with systemd 204-14~bpo70+1

As systemd is in constant development and Jessie is currently running version 215-5+b1 it maybe resolved in more recent versions than 204-14.

 

The solution provided under https://bugzilla.redhat.com/show_bug.cgi?id=626477 suggests to killall ssh sessions, when stopping sshd. I prefer to have at least one ssh session open to my server when restarting ssh, if something goes wrong.

 

Therefore I added a service, to solve this under the current Debian Wheezy version I am running.

 

/etc/systemd/system/ssh-user-sessions.service:

 

[Unit]

Description=Shutdown all ssh sessions before network

After=network.target

 

[Service]

TimeoutStartSec=0

Type=oneshot

RemainAfterExit=yes

ExecStart=/bin/true

ExecStop=/usr/bin/killall sshd

 

When starting, this service does simply nothing (/bin/true). But due to the statement "After=network.target" it kills all ssh processes before shutting down the network.

 

Works for me :-)

 

Cheers

 

Tom


Reply to: