#! /bin/sh
while true
do
who | cut -d " " -f1 | sort> old.txt
sleep 3
who | cut -d " " -f1 | sort> new.txt
comm old.txt new.txt -2 -3 >> logOneTime.txt
comm old.txt new.txt -1 -3 > newLog.txt
num=0
cat newLog.txt | while read line
do
if grep $line['-'] user.deny>/dev/null
then
if grep $line logOneTime.txt>/dev/null
then
fullName=`grep $line['-'] user.deny | cut -d "-" -f2`
num=`expr $num + 1`
echo -e "The user $fullName (on the denial list) has logged in more than once!\n"
fi
fi
done
if [ $num -eq 0 ]
then
echo -e "No user on the user.deny list has multiple logins\n"
fi
done
while true
doshell脚本示例,运行无限循环的shell脚本来检测拒绝列表上的用户是否登录到UNIX系统多于一次。
最新推荐文章于 2025-06-19 11:20:06 发布
本文介绍了一个使用Shell脚本来监控用户登录行为的示例。该脚本通过比较前后两次获取的登录用户列表来判断是否有用户多次登录的情况,并且特别关注黑名单上的用户是否有多次登录的行为。
1554

被折叠的 条评论
为什么被折叠?



