陈佳浩
陈佳浩
发布于 2024-06-28 / 22 阅读
0
0

查看登录失败的IP以及用户名

#!/bin/bash
echo "本机失败连接共`cat /var/log/secure|grep -E "Failed password|Invalid user"|wc -l`次"
echo "root失败连接前五"
cat /var/log/secure|grep 'Failed password for root from'|awk -F" " '{print $11}'|sort -n|uniq -c|sort -nr|awk -F" " '{print "异常IP "$2,"暴力破解了 "$1" 次"}'|head -n5
echo "非正确用户前五"
cat /var/log/secure|grep "Invalid user"|awk -F" " '{print $8}'|sort -n|uniq -c|sort -nr|awk -F" " '{print "非正确用户 "$2,"SSH连接了 "$1" 次"}'|head -n5

评论