Last active
July 5, 2021 01:23
-
-
Save pankpan/e010fa40f75ebe103bd154b7eb1ab367 to your computer and use it in GitHub Desktop.
Force kick out user by IP address for Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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