SSH 连接限制脚本
内容纲要

限制连接ssh服务失败超过10次的IP

#!/bin/bash
# Author: Auroot
# Script name:sms (SSH Manager Scripts) 
# Explain: 禁止连接ssh服务失败超过10次的IP;
# Home URL: : https://www.auroot.cn

awk '/Failed/{print $(NF-3)}' < /var/log/secure | sort | uniq -c | awk '{print $2"="$1;}' > /usr/local/bin/black.list
TIME=$(date "+%Y-%m-%d %H:%M:%S")
ip_list=$(cat /usr/local/bin/black.list)
echo "${TIME}: The rejected IP address is as follows. " >> /root/ssh_deny.log # 输出到日志文件中;
for i in $ip_list
do
    IP=$(echo "$i" | awk -F= '{print $1}')
    NUM=$(echo "$i" | awk -F= '{print $2}')
    if [ "${#NUM}" -gt 1 ]; then
        grep "$IP" /etc/hosts.deny > /dev/null
        if [ $? -gt 0 ]; then
            echo "sshd:${IP}:deny" >> /etc/hosts.deny
        fi 
        echo -e "${IP} / ${NUM}" >> /root/ssh_deny.log  # 输出到日志文件中;
    fi
done
echo -e "is denied now.\n\n" >> /root/ssh_deny
echo "Execution complete."
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇