Score:0

fail2ban does not start jails on cenots 7

mx flag

SOLVED - sshd conf file was in wrong directory and with wrong extension

i have fallowed this tutorial htf and everything went smoothly, fail2ban starts nicely, i disabled selinux just in case, but sshd jail just does not start. I tried messing with config and when there is some mistake fail2ban does not start but when i remove stuff i changed then it starts but there are no jails.

so fallowing the tutorial i made file /etc/fail2ban/sshd.local

[sshd]
enabled = true
port = ssh
action = firewallcmd-ipset
logpath = %(sshd_log)s
maxretry = 5
bantime = 86400

i also tried to put path to logfile( logpath = /var/log/secure) instead of logpath = %(sshd_log)s but there is still no sshd jail:

Status
|- Number of jail:  0
`- Jail list:   

i changed logging level to DEBUG in /etc/fail2ban/fail2ban.conf

[DEFAULT]

# Option: loglevel
# Notes.: Set the log level output.
#         CRITICAL
#         ERROR
#         WARNING
#         NOTICE
#         INFO
#         DEBUG
# Values: [ LEVEL ]  Default: ERROR
#
loglevel = DEBUG

with a bit more loggin inside of /var/log/fail2ban.log but i only get a tiny bit more logging which is irrelevant to jails.

2021-07-14 19:14:49,952 fail2ban.server         [19586]: INFO    Starting Fail2ban v0.11.1
2021-07-14 19:14:49,953 fail2ban.server         [19586]: DEBUG   Creating PID file /var/run/fail2ban/fail2ban.pid
2021-07-14 19:14:49,953 fail2ban.observer       [19586]: INFO    Observer start...
2021-07-14 19:14:49,954 fail2ban.server         [19586]: DEBUG   Starting communication
2021-07-14 19:14:49,961 fail2ban.database       [19586]: INFO    Connected to fail2ban persistent database '/var/lib/fail2ban/fail2ban.sqlite3'
2021-07-14 19:14:49,964 fail2ban.transmitter    [19586]: DEBUG   Status: ready

I also made changes in /etc/fail2ban/jail.local where i replaced:

backend = auto

to

backend = polling

i was wondering if anyone know what tools are on my disposal to debug not working jails?

djdomi avatar
za flag
how should `sshd.local` be fetched by any config file? i only know about `jail.local`
Score:0
cz flag

You placed your jail configuration file in the wrong directory.

To wit:

/etc/fail2ban/sshd.local

Fail2ban will never read this file because it is misplaced.

Jail definitions should be placed in the /etc/fail2ban/jail.d directory with a name ending in .conf. A quick and dirty one off can also be placed in /etc/fail2ban/jail.local but this is less maintainable.

Belutak avatar
mx flag
wow you are right, i read the tutorial million times to check if i did everything correctly and somehow i keep making the same mistake. Thank you
Michael Hampton avatar
cz flag
@Belutak Remember to mark it as solved by clicking the tick mark so that it turns solid green.
Belutak avatar
mx flag
i thought its in my post and took me a wile to find it :D
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.