1、监控ssh访问IP
netstat -ntp |grep sshd
2、查看最近登录用户
last
3、查看访问日志
more /var/log/secure
监控脚本,可以监控ssh暴力,如果输入错误密码超过5次 则禁止ssd登录
扫描二维码关注公众号,回复:
363794 查看本文章
#! /bin/bash
cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /root/black.txt
DEFINE="5"
for i in `cat /root/black.txt`
do
IP=`echo $i |awk -F= '{print $1}'`
NUM=`echo $i|awk -F= '{print $2}'`
if [ $NUM -gt $DEFINE ]
then
grep $IP /etc/hosts.deny > /dev/null
if [ $? -gt 0 ]
then
echo $IP
echo "sshd:$IP:deny" >> /etc/hosts.deny
fi
fi
done
以上脚本可以配合/etc/hosts.deny和/etc/hosts.allow这两个文件一起使用