Skip to content

Instantly share code, notes, and snippets.

@h-otter
Last active March 4, 2017 00:05
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 h-otter/530fb7da6bcaaf77b537c4337ccb5aa9 to your computer and use it in GitHub Desktop.
Save h-otter/530fb7da6bcaaf77b537c4337ccb5aa9 to your computer and use it in GitHub Desktop.
#!/bin/bash -eu
usage_exit() {
echo "Usage: $0 [-d user] [-u user]" 1>&2
echo " -d: disable deny access from user" 1>&2
echo " -u: kick $1 and deny access from user" 1>&2
exit 1
}
kick_user(){
echo [+] kicking $1 and deny access
{
usermod -L $1
} || {
echo [-] if you are not root, please execute with sudo
exit 1
}
pkill -KILL -u $1
#echo [*] still logged in
#last | grep logged
echo [*] w command
w
su -
exit 0
}
allow_access(){
echo [+] allow access
{
usermod -U $1
} || {
echo [-] if you are not root, please execute with sudo
exit 1
}
rm /root/.bash_history
exit 0
}
while getopts :d:u:h OPT
do
case $OPT in
d) allow_access $OPTARG
;;
u) kick_user $OPTARG
;;
h) usage_exit
;;
\?) usage_exit
;;
esac
done
usage_exit
@palloc
Copy link

palloc commented Mar 3, 2017

ssh復旧時にsyslog等を消す動作をフックさせて
/bin/nologon

@h-otter
Copy link
Author

h-otter commented Mar 3, 2017

未検証

auditについて調査

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment