请支援我一脚本,fail2ban
不会用啊。
我在纳闷我的服务器总感觉很卡,原来是有暴力登录脚本一直在尝试登录我的服务器。
╭─root@VM-16-11-ubuntu ~
╰─# lastb | less
ctr ssh:notty 185.252.178.107 Fri Jan 27 05:17 - 05:17 (00:00)
ctr ssh:notty 185.252.178.107 Fri Jan 27 05:17 - 05:17 (00:00)
gujiongh ssh:notty 185.252.178.107 Fri Jan 27 05:17 - 05:17 (00:00)
gujiongh ssh:notty 185.252.178.107 Fri Jan 27 05:17 - 05:17 (00:00)
kian ssh:notty 185.252.178.107 Fri Jan 27 05:17 - 05:17 (00:00)
kian ssh:notty 185.252.178.107 Fri Jan 27 05:17 - 05:17 (00:00)
cuilingh ssh:notty 185.252.178.107 Fri Jan 27 05:16 - 05:16 (00:00)
cuilingh ssh:notty 185.252.178.107 Fri Jan 27 05:16 - 05:16 (00:00)
gilad ssh:notty 185.252.178.107 Fri Jan 27 05:16 - 05:16 (00:00)
gilad ssh:notty 185.252.178.107 Fri Jan 27 05:16 - 05:16 (00:00)
fds ssh:notty 185.252.178.107 Fri Jan 27 05:15 - 05:15 (00:00)
fds ssh:notty 185.252.178.107 Fri Jan 27 05:15 - 05:15 (00:00)
chengyan ssh:notty 185.252.178.107 Fri Jan 27 05:15 - 05:15 (00:00)
chengyan ssh:notty 185.252.178.107 Fri Jan 27 05:15 - 05:15 (00:00)
yixuanhu ssh:notty 185.252.178.107 Fri Jan 27 05:14 - 05:14 (00:00)
yixuanhu ssh:notty 185.252.178.107 Fri Jan 27 05:14 - 05:14 (00:00)
dsm ssh:notty 185.252.178.107 Fri Jan 27 05:14 - 05:14 (00:00)
dsm ssh:notty 185.252.178.107 Fri Jan 27 05:14 - 05:14 (00:00)
root ssh:notty 185.252.178.107 Fri Jan 27 05:13 - 05:13 (00:00)
wangl ssh:notty 185.252.178.107 Fri Jan 27 05:13 - 05:13 (00:00)
wangl ssh:notty 185.252.178.107 Fri Jan 27 05:13 - 05:13 (00:00)
root ssh:notty 185.252.178.107 Fri Jan 27 05:12 - 05:12 (00:00)
emmanuel ssh:notty 185.252.178.107 Fri Jan 27 05:12 - 05:12 (00:00)
emmanuel ssh:notty 185.252.178.107 Fri Jan 27 05:12 - 05:12 (00:00)
mdzhou ssh:notty 185.252.178.107 Fri Jan 27 05:12 - 05:12 (00:00)
mdzhou ssh:notty 185.252.178.107 Fri Jan 27 05:12 - 05:12 (00:00)
trenz ssh:notty 185.252.178.107 Fri Jan 27 03:19 - 03:19 (00:00)
lixi ssh:notty 185.252.178.107 Fri Jan 27 03:19 - 03:19 (00:00)
lixi ssh:notty 185.252.178.107 Fri Jan 27 03:19 - 03:19 (00:00)
....
root ssh:notty 211.115.91.20 Fri Jan 27 01:04 - 01:04 (00:00)
es ssh:notty 211.115.91.20 Thu Jan 26 23:36 - 23:36 (00:00)
es ssh:notty 211.115.91.20 Thu Jan 26 23:36 - 23:36 (00:00)
root ssh:notty 211.115.91.20 Thu Jan 26 05:25 - 05:25 (00:00)
...
root ssh:notty 220.174.25.172 Tue Jan 24 23:19 - 23:19 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:18 - 23:18 (00:00)
root ssh:notty 220.174.25.172 Tue Jan 24 23:17 - 23:17 (00:00)
...
---还有很多其它 ip---
这个脚本我想可以设置,每 X 分钟执行一次这个脚本吧。 我数了一下,最多的时候一分钟登录我 23 次(虽然它失败了),照这频率,5 分钟也足够它试 100 次了。 如果被别人尝试登录服务器,对服务器也是一种损失啊,敲这 log 记录,都 18M 了。。
╭─root@VM-16-11-ubuntu ~
╰─# ll /var/log/btmp
Permissions Size User Date Modified Name
.rw-rw---- 18M root 27 Jan 05:17 /var/log/btmp
可以看到上面的最后 Modified
是在 05:17 ,因为我搜了一个 ban ip 的命令,好像确实管用了
iptables -I INPUT -s 185.252.178.107 -j DROP
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.