fail2ban 원 키 설치 스 크 립 트

fail2ban 원 키 설치 스 크 립 트
#!/bin/bash
# Copyright (c) 2015.7  Fenei
# BY:  
#             
# 2015 7 1   2 
# denyhosts auto install and configure shell
# VER. 1.1.0 - http://www.fenei.net
# fail2ban       
# 2015 7 1   2 
# 
#       Redhat、Centos      fail2ban       。
#           。
#                   IP     "ess /etc/fail2ban/jail.conf"    ignoreip  。
#       ,    ,      ,      。
#
# Fenei@ Sinpul Network
# VER. 1.1.0 - http://www.fenei.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#=====================================================================
 
 
#      ,        EPEL 
a=$(cat /etc/redhat-release|cut -b1-16)
b=$(cat /etc/redhat-release|cut -b1-18)
v=$(uname -r |cut -d . -f 5)
 if [[ $a == "CentOS release 6" ]]
 then
                        if [ $v == "x86_64" ]
                        then
      echo -e "\033[32;49;1m ======        $b 64bit====== \033[39;49;0m"
                     read -p "        ." var
       wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
       rpm -ivh epel-release-latest-6.noarch.rpm
                        else
                        echo -e "\033[32;49;1m ======        $b 32bit====== \033[39;49;0m"
      read -p "        ." var
       wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
       rpm -ivh epel-release-latest-6.noarch.rpm
      fi
 elif [[ $a == "CentOS release 5" ]]
 then
                        if [ $v == "x86_64" ]
                        then
                        echo -e "\033[32;49;1m ======        $b 64bit====== \033[39;49;0m"
      read -p "        ." var
       wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm
       rpm -ivh epel-release-latest-5.noarch.rpm
                        else
                        echo -e "\033[32;49;1m ======        $b 32bit====== \033[39;49;0m"
      read -p "        ." var
       wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm
       rpm -ivh epel-release-latest-5.noarch.rpm
      fi
 elif [[ $a == "CentOS release 7" ]]
 then
                        echo -e "\033[32;49;1m ======        $b 64bit====== \033[39;49;0m"
      read -p "        ." var
       wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
       rpm -ivh epel-release-latest-7.noarch.rpm
 else
  echo "        \"Centos\",         !"
   read -p "        ." var
   wget --no-check-certificate https://codeload.github.com/fail2ban/fail2ban/tar.gz/0.9.1 -O fail2ban-0.9.1.tar.gz
   tar  zxvf fail2ban-0.9.1.tar.gz
   cd fail2ban-0.9.1
   python setup.py install
   #        
   sed -i '33s/SYSLOG/\/var\/log\/fail2ban.log/g' /etc/fail2ban/fail2ban.conf
 fi
 
 #    mirrorlist
su -c "sed -i 's|^#baseurl|baseurl| ; s|^mirrorlist|#mirrorlist|' /etc/yum.repos.d/*"
#  fail2ban
yum install fail2ban -y
#  fail2ban  
service fail2ban restart
#  fail2ban    
chkconfig fail2ban on

echo -e "\033[32;49;1m
************************************************************************************
      IP 'sudo iptables --list -n' 'sudo fail2ban-client status ssh-iptables'
      fail2ban     IP  ,     iptables  :
sudo iptables -D fail2ban-SSH -s IP -j DROP
       :
sudo fail2ban-client set ssh-iptables unbanip IP 
************************************************************************************
\033[39;49;0m"

좋은 웹페이지 즐겨찾기