Centos6.4 Installation Fail2ban anti-violence hack

Source: Internet
Author: User
Tags syslog

Centos6.4 Installation Fail2ban anti-violence hack

One. Installation

Curl-o https://codeload.github.com/fail2ban/fail2ban/tar.gz/0.9.00.9. 0 0.9. 0  0.9. 0 . TAR.GZCD Fail2ban-0.9. 0/python setup.py buildpython setup.py install

Two. Configuration (anti-SSH violence)

  

vi/etc/fail2ban/jail.conf[ssh-iptables]enabled  truefilter   =  Sshdaction   = iptables[name=ssh, port=ssh, protocol=TCP]           sendmail-whois[name=ssh, [email protected], [email protected], sendername="192.168.1.25"]logpath  =/var/log/5

  

Three. Configure the boot startup script

Fail2ban-client-x Startfail2ban-client-x Stopfail2ban-client-x reload[[email protected]~]# cat/etc/init.d/Fail2ban #!/bin/bash## chkconfig:- the  ,# Processname:fail2ban-server# config:/etc/fail2ban/fail2ban.conf# pidfile:/var/run/fail2ban/fail2ban.pid# Description:fail2ban isa daemon to ban hosts the cause multiple authentication errors#### BEGIN INIT info# provides:fail2ban# required-Start: $local _fs $remote _fs# Required-Stop: $local _fs $remote _fs# should-Start: $time $network $syslog iptables firehol shorewall ferm# should-Stop: $network $syslog iptables firehol shorewall ferm# Default-start:3 4 5# Default-stop:0 1 6# Short-description:start/Stop fail2ban# Description:start/Stop Fail2ban, a daemon to ban hosts this cause multiple authentication errors### END INIT info# Source function libra Ry. /etc/rc.d/init.d/functions# Check that the config file exists[-F/ETC/FAIL2BAN/FAIL2BAN.CONF] | | Exit0Fail2ban="/usr/bin/fail2ban-client"Prog=fail2ban-Serverlockfile=${lockfile-/var/Lock/subsys/Fail2ban}socket=${socket-/var/run/fail2ban/Fail2ban.sock}pidfile=${pidfile-/var/run/fail2ban/Fail2ban.pid} RETVAL=0start () {echo-N $"starting Fail2ban:"${fail2ban}-X Start >/dev/NULLRETVAL=$?if[$RETVAL =0 ]; Then Touch ${lockfile} echo_successElseecho_failure fi echoreturn$RETVAL}stop () {echo-N $"stopping Fail2ban:"${fail2ban} Stop>/dev/NULLRETVAL=$?if[$RETVAL =0 ]; Then RM-f ${lockfile} ${pidfile} echo_successElseecho_failure fi echoreturn$RETVAL}reload () {echo"Reloading Fail2ban:"${fail2ban} Reload RETVAL=$?Echoreturn$RETVAL}# See how we were called. Case " $" inchstart) Status-P ${pidfile} ${prog} >/dev/NULL 2>&1&& exit0start;;    stop) stop;;    reload) reload;;    restart) stop start;; Status) Status-P ${pidfile} ${prog} RETVAL=$?[$RETVAL=0] &&${fail2ban} status;; *) echo $"Usage:fail2ban {Start|stop|restart|reload|status}"RETVAL=2esacexit $RETVAL

Four. Start

chkconfig fail2banon/etc/init.d/fail2ban start

Centos6.4 Installation Fail2ban anti-violence hack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.