ssh-session-cleanup 239 B

1234567891011
  1. #! /bin/sh
  2. ssh_session_pattern='sshd: \S.*@pts/[0-9]+'
  3. IFS="$IFS@"
  4. pgrep -a -f "$ssh_session_pattern" | while read pid daemon user pty; do
  5. echo "Found ${daemon%:} session $pid on $pty; sending SIGTERM"
  6. kill "$pid" || true
  7. done
  8. exit 0