[Unit]
Description=Shutdown all ssh sessions before network
DefaultDependencies=no
Before=network.target shutdown.target

[Service]
Type=oneshot
ExecStart=/bin/sh -c "/usr/bin/killall sshd; sleep 2; :"

[Install]
WantedBy=poweroff.target halt.target reboot.target
