You are not logged in.

#1 2016-12-01 20:23:50

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

systemctl stop sshd does not terminate active ssh sessions.

If I login to the system via ssh and then stop the sshd server with "systemctl stop sshd", the system does not accept new ssh connection anymore. But active sessions continue to be active. Is it a normal behaviour? I would have expected that stopping sshd would terminate any current inbound ssh connection.

Last edited by olive (2016-12-01 20:25:59)

Offline

#2 2016-12-01 20:45:46

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: systemctl stop sshd does not terminate active ssh sessions.

It's expected. That way you can restart sshd when you are using it, and not be disconnected.

Offline

#3 2016-12-02 14:38:31

solar
Member
Registered: 2011-03-01
Posts: 77

Re: systemctl stop sshd does not terminate active ssh sessions.

This is as ataraxia says, expected. However, if your server/machines are in same location like a home net or office), you could still use iptables/nft to change the behaviour of established packets I would think to alter that behaviour.

I say local because if your machine is remotely, you really _want_ that default behaviour smile You can of course also create a custom service file, which fires when sshd is stopped/restarted/disabled say, which would pgrep all ssh sessions and kill them for example.

Last edited by solar (2016-12-02 14:38:50)


I am hilariously insane. yup. you won't notice though.. I promise...I think.

Offline

#4 2016-12-02 16:05:59

loqs
Member
Registered: 2014-03-06
Posts: 17,372

Re: systemctl stop sshd does not terminate active ssh sessions.

Would not setting

KillMode=control-group

in sshd.service give the desired behavior? ( sorry not tested this )

Offline

Board footer

Powered by FluxBB