我刚刚cat /var/log/auth.log
登录并看到,有很多| grep "Failed password for"
记录。
但是,有两种可能的记录类型-有效/无效用户。它使我的尝试变得复杂| cut
他们的。
我想看到创建一个列表(文本文件),其中包含可能的攻击者的IP地址以及每个IP地址的尝试次数。有什么简单的方法可以创建它吗?
另外,仅涉及ssh
:/var/log/auth.log
在列出可能的攻击者时,我应该考虑所有记录吗?
我的带有隐藏数字的“ auth.log”示例:
cat /var/log/auth.log | grep "Failed password for" | sed 's/[0-9]/1/g' | sort -u | tail
结果:
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for invalid user ucpss from 111.11.111.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for invalid user vijay from 111.111.11.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for invalid user webalizer from 111.111.11.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for invalid user xapolicymgr from 111.111.11.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for invalid user yarn from 111.111.11.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for invalid user zookeeper from 111.111.11.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for invalid user zt from 111.11.111.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for mysql from 111.111.11.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for root from 111.11.111.111 port 11111 ssh1
Mar 11 11:11:11 vm11111 sshd[111]: Failed password for root from 111.111.111.1 port 11111 ssh1
/etc/ssh/sshd_config
...查找设置PasswordAuthentication no
,PermitRootLogin without-password
然后...在进入auth.log之前,所有此类密码尝试都将被阻止。