Git Product home page Git Product logo

fail2ban-sms's Introduction

fail2ban-sms

Fail2ban configuration to send a SMS after blocking a SSH non authorized connection.


El primer paso es crearse una cuenta gratuita en Twilio

Una vez tengamos la cuenta creada instalaremos fail2ban, en este caso, lo hemos hecho sobre Debian.

aptitude install fail2ban

Una vez instalado, es necesario crear la acción en fail2ban que envíe un SMS.

vi /etc/fail2ban/action.d/sms.conf

Ahora configuramos fail2ban para que al bloquear una conexión SSH, ejecute esta acción. Es necesario modificar la directiva "[ssh]"

vi /etc/fail2ban/jail.conf

[ssh]

enabled  = true
port     = ssh
filter   = sshd
logpath  = /var/log/auth.log
maxretry = 6
action   = iptables[name=SSH, port=ssh, protocol=tcp]
           sms

Una vez configurado fail2ban, es necesario crear el script que enviará los SMS.

vi /root/scripts/sms.conf
chmod 755 /root/scripts/sms.conf

Por último, creamos el fichero con las credenciales, el cual solo tendrá permisos de lectura por el usuario root para securizarlo.

vi /root/scripts/secret.conf
chmod 755 /root/scripts/secret.conf

Ahora probamos el script para verificar que envía los SMS Correctamente

/root/scripts/sms.sh start && /root/scripts/sms.sh ban 127.0.0.1

Y por último, solo queda reiniciar el servicio de fail2ban para que actualize los cambios

systemctl restart fail2ban

fail2ban-sms's People

Contributors

dtrinf avatar

Stargazers

 avatar Mathieu Lory avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.