diff options
author | Colin Watson <cjwatson@debian.org> | 2016-07-22 16:51:08 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2016-07-22 16:51:08 +0100 |
commit | b66f1de1c94fcf912b3a1bc0cd73c3b73cdae8a1 (patch) | |
tree | 76bc05af9b826471b6c1af83ccf9ba572e9e05d3 /debian/systemd/ssh-session-cleanup | |
parent | 4e620d6d9ebe0eda9ceddb28134d1fc465dd925c (diff) |
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).
Diffstat (limited to 'debian/systemd/ssh-session-cleanup')
-rwxr-xr-x | debian/systemd/ssh-session-cleanup | 11 |
1 files changed, 11 insertions, 0 deletions
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 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | ssh_session_pattern='sshd: \S.*@pts/[0-9]+' | ||
4 | |||
5 | IFS="$IFS@" | ||
6 | pgrep -a -f "$ssh_session_pattern" | while read pid daemon user pty; do | ||
7 | echo "Found ${daemon%:} session $pid on $pty; sending SIGTERM" | ||
8 | kill "$pid" || true | ||
9 | done | ||
10 | |||
11 | exit 0 | ||