Code Monkey home page Code Monkey logo

fail2ban-ssh-honeypot's Introduction

fail2ban-ssh-honeypot

Fail2ban jail for creating port 22 (SSH) honeypot

Tired of endless ssh bruteforce attacks ? Even if you are using a certificate or have disabled ssh access completely it will catch a whole lot of compromised IP's and consequently stop some other attack vectors on other ports and services. Port 22 is never missed by a port scan either so you might catch some of these too.

Installation

  1. If you have SSH access, set the service to listen to some port other than 22, any high number, non reserved port will do.
  2. create iptable chain and add rules:
iptables -N HONEYPOT
iptables -A HONEYPOT -j LOG --log-prefix "honeypot: " --log-level 6
iptables -A HONEYPOT -j DROP
iptables -A INPUT -p tcp -m tcp --dport 22 --tcp-flags FIN,SYN,RST,ACK SYN -j HONEYPOT
iptables-save > ~/iptables.save
  1. add this code block to your jail.local
[honeypot]
enabled  = true
filter   = honeypot
logpath  = /var/log/messages
banaction = iptables-allports
bantime  = 604800
maxretry = 1
  1. copy honeypot.conf to /etc/fail2ban/filter.d/honeypot.conf
  2. (if installing jail for the first time) run service fail2ban reload
  3. run fail2ban-client reload honeypot

Warning

Don't lock yourself out of your box ! Be aware to connect to the new port from now on. Have a backup plan, lower the bantime, raise the failure attempts (maxretry), whitelist yourself etc...

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.