久久青草精品A片狠狠,日韩欧美视频一区二区,亚洲国码AV日韩,国产精品黄在

幫助中心 >  技術知識庫 >  云服務器 >  服務器教程 >  CentOS7防止惡意破解root賬戶的腳本

CentOS7防止惡意破解root賬戶的腳本

2019-08-27 23:12:36 8675

#!/bin/bash


#Denyhosts SHELL SCRIPT


#2017-01-24


#


#When a IP is accessed 50 times through sshd, it is written to the hosts.deny file, 


#which prohibits the IP from connecting to the host via sshd


#


#Add to timing task




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




DEFINE=50


for i in $(cat /root/black.txt)


do


    IP=$( $i | awk -F'=' '{print $1}')


    NUM=$( $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


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: