Skip to content

Instantly share code, notes, and snippets.

@pankpan
Last active July 5, 2021 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pankpan/e010fa40f75ebe103bd154b7eb1ab367 to your computer and use it in GitHub Desktop.
Save pankpan/e010fa40f75ebe103bd154b7eb1ab367 to your computer and use it in GitHub Desktop.
Force kick out user by IP address for Linux
#!/bin/sh
if [ -z $1 ] ; then
echo "`basename $0` {ip}"
else
TEMP=/tmp/psauxw.tmp
ps auxw > $TEMP
for T in `w | grep -w $1 | awk '{print $2}'`
do
echo Logout $T
grep -w $T $TEMP | awk '{print $2}' | xargs kill -9
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment