Created
February 28, 2019 12:01
-
-
Save 0x27/0f0ee4c2613457dfcf7ee318b892201c to your computer and use it in GitHub Desktop.
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/bash | |
echo "SSH hangup user tool. For killing other users connections." | |
if [ $# -eq 0 ] | |
then | |
echo "use: $0 <PTS number to kill>" | |
exit | |
fi | |
echo "Terminating PTS/$1" | |
OWNER=$(stat -c '%U' /dev/pts/$i) | |
SSH_PID=$(pgrep -a sshd | grep pts/$1 | cut -d ' ' -f 1) | |
echo "Owner of PTS is $OWNER" | |
echo "SSH PID is $SSH_PID" | |
echo "You have been expunged." > /dev/pts/$1 | |
sleep 2 # we sleep for a sec here, to ensure they get the message | |
kill -9 $SSH_PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment