From b66f1de1c94fcf912b3a1bc0cd73c3b73cdae8a1 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 22 Jul 2016 16:51:08 +0100 Subject: Add a session cleanup script and a systemd unit file to trigger it, which serves to terminate SSH sessions cleanly if systemd doesn't do that itself, often because libpam-systemd is not installed (thanks, Vivek Das Mohapatra, Tom Hutter, and others; closes: #751636). --- debian/systemd/ssh-session-cleanup | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 debian/systemd/ssh-session-cleanup (limited to 'debian/systemd/ssh-session-cleanup') diff --git a/debian/systemd/ssh-session-cleanup b/debian/systemd/ssh-session-cleanup new file mode 100755 index 000000000..f283cc967 --- /dev/null +++ b/debian/systemd/ssh-session-cleanup @@ -0,0 +1,11 @@ +#! /bin/sh + +ssh_session_pattern='sshd: \S.*@pts/[0-9]+' + +IFS="$IFS@" +pgrep -a -f "$ssh_session_pattern" | while read pid daemon user pty; do + echo "Found ${daemon%:} session $pid on $pty; sending SIGTERM" + kill "$pid" || true +done + +exit 0 -- cgit v1.2.3