Skip to content

Instantly share code, notes, and snippets.

@diyfr
Last active February 16, 2018 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diyfr/6fb5c33bcda89b4ac6f01a65e0b3c179 to your computer and use it in GitHub Desktop.
Save diyfr/6fb5c33bcda89b4ac6f01a65e0b3c179 to your computer and use it in GitHub Desktop.
Docker & Fail2ban (tests)
#/etc/fail2ban/filter.d/docker-gogs-sshd.conf
[INCLUDES]
before = common.conf
[Definition]
_daemon = sshd
failregex = .+sshd.+User .+ from <HOST> not allowed because not listed in AllowUsers\s*.+$
.+sshd.+(?:llegal|nvalid) user .* from <HOST>\s*.+$
.+sshd.+User .+ from <HOST> not allowed because listed in DenyUsers\s*.+$
.+sshd.+User .+ from <HOST> not allowed because not in any group\s*.+$
.+sshd.+refused connect from \S+ \(<HOST>\)\s*.+$
.+sshd.+Received disconnect from <HOST>: 3: \S+: Auth fail.+$
.+sshd.+User .+ from <HOST> not allowed because a group is listed in DenyGroups\s*.+$
.+sshd.+User .+ from <HOST> not allowed because none of user's groups are listed in AllowGroups\s*.+$
ignoreregex =
[Init]
maxlines = 10
journalmatch = _SYSTEMD_UNIT=sshd.service + _COMM=sshd
#/etc/fail2ban/jail.d/gogs_sshd.conf
[gogs_sshd]
enabled = true
port = ssh,http,https
filter = docker-gogs-sshd
action = iptables-allports
maxretry=3
logpath = /var/lib/docker/containers/*/*-json.log
## NOTES : http://www.the-lazy-dev.com/en/install-fail2ban-with-docker/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment