[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;:" [Install] WantedBy=poweroff.target halt.target reboot.target