Denyhosts shell script

简介: Denyhosts shell script
#!/bin/sh
#Denyhosts shell script


cat /var/log/secure | awk '/Failed/{print $(NF-3)}' | sort | uniq -c | awk '{print $2"="$1;}' > /root/blacklist.txt

DEFINE="5"

for i in `cat /root/blacklist.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 "sshd:$IP" >> /etc/hosts.deny
fi
fi
done


* */1 * * * sh /root/shell/deny-ssh.sh
目录
相关文章
|
3月前
|
Shell 开发工具
学习简单的shell script
【1月更文挑战第3天】学习简单的shell script。
48 3
|
Shell Android开发 C++
利用Wrap Shell Script定位Android Native内存泄漏
## 前提条件 - Android版本为8.0以上 ## 环境配置 - cd到/src/main目录下,新建shell目录,同时shell目录下配置与libs目录下相同平台的目录,如下app下的层级结构,可看到shell/lib下具有与libs下相同的平台目录结构 ```c ── AndroidManifest.xml ├── java ├── libs │   ├── a
3416 0
|
3月前
|
Shell 开发工具
编写与执行一个shell script
【1月更文挑战第3天】编写与执行一个shell script。
48 1
|
8月前
|
Shell
12.3.3 Shell script 的默认变量($0, $1...)
12.3.3 Shell script 的默认变量($0, $1...)
51 0
|
9月前
|
JavaScript 前端开发 关系型数据库
Shell script + crontab实现Mysql定时备份
Shell script + crontab实现Mysql定时备份
79 0
Shell script + crontab实现Mysql定时备份
|
10月前
|
JavaScript 前端开发 Shell
Shell 和 Shell 脚本 (Shell Script)
Shell 和 Shell 脚本 (Shell Script)
210 0
|
Shell
shell script快速入门-基础语法
shell script快速入门-基础语法