RE
Tout d’abord, merci pour la réponse.
Si je comprend bien, une fois installé fail2ban, tu as juste créé le fichier /etc/fail2ban/jail.d/local.conf
[DEFAULT]
bantime = 3600
sender = fail2ban@example.com
destemail = root
action = %(action_mwl)s
[sshd]
enabled = true
Sans rien modifier d’autre ?
Je suppose que tu as lancer fail2ban
systemctl start fail2ban
Ma config est dans jail.conf au lieu local.conf, sans oublier jail.local et fail2ban.conf qu’il a fallu modifier
Veuillez fournir plus de détails sur ce qui échoue ?
Quand j’ai installé fail2ban, je l’ai démarré , puis :
systemctl status fail2ban
[root@vmxxx ~]# systemctl status fail2ban
? fail2ban.service - Fail2Ban Service
Loaded: loaded (/usr/lib/systemd/system/fail2ban.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2021-07-26 04:15:55 EDT; 14min ago
Docs: man:fail2ban(1)
Process: 83060 ExecStart=/usr/bin/fail2ban-server -xf start (code=exited, status=255)
Process: 83059 ExecStartPre=/bin/mkdir -p /run/fail2ban (code=exited, status=0/SUCCESS)
Main PID: 83060 (code=exited, status=255)
juil. 26 04:15:54 vmxxx.hosteur.net systemd[1]: Starting Fail2Ban Service...
juil. 26 04:15:54 vmxxx.hosteur.net systemd[1]: Started Fail2Ban Service.
juil. 26 04:15:55 vmxxx.hosteur.net fail2ban-server[83060]: ERROR: File contains no section headers.
juil. 26 04:15:55 vmxxx.hosteur.net fail2ban-server[83060]: file: '/etc/fail2ban/fail2ban.conf', line: 9
juil. 26 04:15:55 vmxxx.hosteur.net fail2ban-server[83060]: 'loglevel = DEBUG\n'
juil. 26 04:15:55 vmxxx.hosteur.net systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/n/a
juil. 26 04:15:55 vmxxx.hosteur.net systemd[1]: fail2ban.service: Failed with result 'exit-code'.
C’est pour ça qu’on a eu l’idée d’échanger de dossier.
Qu’est-ce que /var/log/fail2ban.log
rapport?
2021-07-26 11:21:26,048 fail2ban.server [83426]: INFO --------------------------------------------------
2021-07-26 11:21:26,048 fail2ban.server [83426]: INFO Starting Fail2ban v0.11.2
2021-07-26 11:21:26,050 fail2ban.observer [83426]: INFO Observer start…
2021-07-26 11:21:26,056 fail2ban.database [83426]: INFO Connected to fail2ban persistent database ‘/var/lib/fail2ban/fail2ban.sqlite3’
2021-07-26 11:21:26,061 fail2ban.database [83426]: WARNING New database created. Version ‘4’
2021-07-26 11:21:26,062 fail2ban.jail [83426]: INFO Creating new jail ‘sshd’
2021-07-26 11:21:26,083 fail2ban.jail [83426]: INFO Jail ‘sshd’ uses systemd {}
2021-07-26 11:21:26,084 fail2ban.jail [83426]: INFO Initiated ‘systemd’ backend
2021-07-26 11:21:26,085 fail2ban.filter [83426]: INFO maxLines: 10
2021-07-26 11:21:26,187 fail2ban.filtersystemd [83426]: INFO [sshd] Added journal match for: ‘_SYSTEMD_UNIT=sshd.service + _COMM=sshd’
2021-07-26 11:21:26,187 fail2ban.filter [83426]: INFO maxRetry: 3
2021-07-26 11:21:26,187 fail2ban.filter [83426]: INFO findtime: 86400
2021-07-26 11:21:26,188 fail2ban.actions [83426]: INFO banTime: 86400
2021-07-26 11:21:26,188 fail2ban.filter [83426]: INFO encoding: UTF-8
2021-07-26 11:21:26,189 fail2ban.jail [83426]: INFO Creating new jail ‘x-ban’
2021-07-26 11:21:26,189 fail2ban.jail [83426]: INFO Jail ‘x-ban’ uses systemd {}
2021-07-26 11:21:26,190 fail2ban.jail [83426]: INFO Initiated ‘systemd’ backend
2021-07-26 11:21:26,194 fail2ban.filter [83426]: INFO maxRetry: 3
2021-07-26 11:21:26,195 fail2ban.filter [83426]: INFO findtime: 86400
2021-07-26 11:21:26,195 fail2ban.actions [83426]: INFO banTime: 86400
2021-07-26 11:21:26,195 fail2ban.filter [83426]: INFO encoding: UTF-8
2021-07-26 11:21:26,196 fail2ban.jail [83426]: INFO Creating new jail ‘dovecot’
2021-07-26 11:21:26,196 fail2ban.jail [83426]: INFO Jail ‘dovecot’ uses systemd {}
2021-07-26 11:21:26,197 fail2ban.jail [83426]: INFO Initiated ‘systemd’ backend
2021-07-26 11:21:26,211 fail2ban.datedetector [83426]: INFO date pattern ''
: {^LN-BEG}TAI64N
2021-07-26 11:21:26,211 fail2ban.filtersystemd [83426]: INFO [dovecot] Added journal match for: ‘_SYSTEMD_UNIT=dovecot.service’
2021-07-26 11:21:26,212 fail2ban.filter [83426]: INFO maxRetry: 5
2021-07-26 11:21:26,212 fail2ban.filter [83426]: INFO findtime: 86400
2021-07-26 11:21:26,212 fail2ban.actions [83426]: INFO banTime: 86400
2021-07-26 11:21:26,212 fail2ban.filter [83426]: INFO encoding: UTF-8
2021-07-26 11:21:26,213 fail2ban.jail [83426]: INFO Creating new jail ‘postfix-sasl’
2021-07-26 11:21:26,213 fail2ban.jail [83426]: INFO Jail ‘postfix-sasl’ uses systemd {}
2021-07-26 11:21:26,214 fail2ban.jail [83426]: INFO Initiated ‘systemd’ backend
2021-07-26 11:21:26,219 fail2ban.filtersystemd [83426]: INFO [postfix-sasl] Added journal match for: ‘_SYSTEMD_UNIT=postfix.service’
2021-07-26 11:21:26,219 fail2ban.filter [83426]: INFO maxRetry: 3
2021-07-26 11:21:26,220 fail2ban.filter [83426]: INFO findtime: 86400
2021-07-26 11:21:26,220 fail2ban.actions [83426]: INFO banTime: 604800
2021-07-26 11:21:26,220 fail2ban.filter [83426]: INFO encoding: UTF-8
2021-07-26 11:21:26,226 fail2ban.filter [83426]: WARNING [sshd] Simulate NOW in operation since found time has too large deviation 1627286669.278524 ~ 1627312886.226111 +/- 60
2021-07-26 11:21:26,226 fail2ban.filter [83426]: WARNING [sshd] Please check jail has possibly a timezone issue. Line with odd timestamp: (‘’, ‘2021-07-26T04:04:29.278524’, ‘vm6-10.hosteur.net sshd[82936]: Accepted password for root from 85.171.104.203 port 59099 ssh2’)
2021-07-26 11:21:26,266 fail2ban.jail [83426]: INFO Jail ‘sshd’ started
2021-07-26 11:21:26,266 fail2ban.filtersystemd [83426]: NOTICE Jail started without ‘journalmatch’ set. Jail regexs will be checked against all journal entries, which is not advised for performance reasons.
2021-07-26 11:21:26,269 fail2ban.filter [83426]: WARNING [x-ban] Simulate NOW in operation since found time has too large deviation 1627227097.905816 ~ 1627312886.269148 +/- 60
2021-07-26 11:21:26,269 fail2ban.filter [83426]: WARNING [x-ban] Please check jail has possibly a timezone issue. Line with odd timestamp: (‘’, ‘2021-07-25T11:31:37.905816’, ‘vm6-10.hosteur.net systemd[1]: Starting Cleanup of Temporary Directories…’)
2021-07-26 11:21:26,300 fail2ban.jail [83426]: INFO Jail ‘x-ban’ started
2021-07-26 11:21:26,303 fail2ban.jail [83426]: INFO Jail ‘dovecot’ started
2021-07-26 11:21:26,308 fail2ban.jail [83426]: INFO Jail ‘postfix-sasl’ started
2021-07-26 11:21:26,423 fail2ban.filter [83426]: INFO [sshd] Found 85.171.104.203 - 2021-07-26 11:21:26
2021-07-26 11:21:26,424 fail2ban.filter [83426]: INFO [sshd] Found 85.171.104.203 - 2021-07-26 11:21:26
2021-07-26 11:21:26,425 fail2ban.filter [83426]: INFO [sshd] Found 85.171.104.203 - 2021-07-26 11:21:26
2021-07-26 11:21:26,438 fail2ban.filter [83426]: INFO [sshd] Found 93.21.95.76 - 2021-07-26 11:21:26
2021-07-26 11:21:26,439 fail2ban.filter [83426]: INFO [sshd] Found 93.21.95.76 - 2021-07-26 11:21:26
2021-07-26 11:21:26,466 fail2ban.actions [83426]: NOTICE [sshd] Ban 85.171.104.203
2021-07-26 11:43:28,896 fail2ban.transmitter [83426]: WARNING Command [‘status’, ‘jail-ssh’] has failed. Received UnknownJailException(‘jail-ssh’,)
2021-07-26 11:44:10,555 fail2ban.actions [83426]: NOTICE [sshd] Unban 85.171.104.203
2021-07-26 12:05:44,440 fail2ban.server [83426]: INFO Shutdown in progress…
2021-07-26 12:05:44,441 fail2ban.observer [83426]: INFO Observer stop … try to end queue 5 seconds
2021-07-26 12:05:44,462 fail2ban.observer [83426]: INFO Observer stopped, 0 events remaining.
2021-07-26 12:05:44,502 fail2ban.server [83426]: INFO Stopping all jails
2021-07-26 12:05:44,615 fail2ban.actions [83426]: NOTICE [dovecot] Flush ticket(s) with iptables-multiport
2021-07-26 12:05:44,616 fail2ban.actions [83426]: NOTICE [postfix-sasl] Flush ticket(s) with iptables-multiport
2021-07-26 12:05:44,616 fail2ban.actions [83426]: NOTICE [x-ban] Flush ticket(s) with iptables-multiport
2021-07-26 12:05:44,846 fail2ban.actions [83426]: NOTICE [sshd] Flush ticket(s) with iptables
2021-07-26 12:05:44,890 fail2ban.jail [83426]: INFO Jail ‘sshd’ stopped
2021-07-26 12:05:44,891 fail2ban.jail [83426]: INFO Jail ‘x-ban’ stopped
2021-07-26 12:05:44,891 fail2ban.jail [83426]: INFO Jail ‘dovecot’ stopped
2021-07-26 12:05:44,891 fail2ban.jail [83426]: INFO Jail ‘postfix-sasl’ stopped
2021-07-26 12:05:44,892 fail2ban.database [83426]: INFO Connection to database closed.
2021-07-26 12:05:44,893 fail2ban.server [83426]: INFO Exiting Fail2ban
2021-07-26 12:05:45,275 fail2ban.server [83683]: INFO --------------------------------------------------
2021-07-26 12:05:45,275 fail2ban.server [83683]: INFO Starting Fail2ban v0.11.2
2021-07-26 12:05:45,276 fail2ban.observer [83683]: INFO Observer start…
2021-07-26 12:05:45,279 fail2ban.database [83683]: INFO Connected to fail2ban persistent database ‘/var/lib/fail2ban/fail2ban.sqlite3’
2021-07-26 12:05:45,280 fail2ban.jail [83683]: INFO Creating new jail ‘sshd’
2021-07-26 12:05:45,293 fail2ban.jail [83683]: INFO Jail ‘sshd’ uses systemd {}
2021-07-26 12:05:45,294 fail2ban.jail [83683]: INFO Initiated ‘systemd’ backend
2021-07-26 12:05:45,294 fail2ban.filter [83683]: INFO maxLines: 10
2021-07-26 12:05:45,355 fail2ban.filtersystemd [83683]: INFO [sshd] Added journal match for: ‘_SYSTEMD_UNIT=sshd.service + _COMM=sshd’
2021-07-26 12:05:45,355 fail2ban.filter [83683]: INFO maxRetry: 3
2021-07-26 12:05:45,356 fail2ban.filter [83683]: INFO findtime: 86400
2021-07-26 12:05:45,356 fail2ban.actions [83683]: INFO banTime: 86400
2021-07-26 12:05:45,356 fail2ban.filter [83683]: INFO encoding: UTF-8
2021-07-26 12:05:45,356 fail2ban.jail [83683]: INFO Creating new jail ‘x-ban’
2021-07-26 12:05:45,357 fail2ban.jail [83683]: INFO Jail ‘x-ban’ uses systemd {}
2021-07-26 12:05:45,357 fail2ban.jail [83683]: INFO Initiated ‘systemd’ backend
2021-07-26 12:05:45,359 fail2ban.filter [83683]: INFO maxRetry: 3
2021-07-26 12:05:45,359 fail2ban.filter [83683]: INFO findtime: 86400
2021-07-26 12:05:45,359 fail2ban.actions [83683]: INFO banTime: 86400
2021-07-26 12:05:45,359 fail2ban.filter [83683]: INFO encoding: UTF-8
2021-07-26 12:05:45,360 fail2ban.jail [83683]: INFO Creating new jail ‘dovecot’
2021-07-26 12:05:45,360 fail2ban.jail [83683]: INFO Jail ‘dovecot’ uses systemd {}
2021-07-26 12:05:45,360 fail2ban.jail [83683]: INFO Initiated ‘systemd’ backend
2021-07-26 12:05:45,368 fail2ban.datedetector [83683]: INFO date pattern ''
: {^LN-BEG}TAI64N
2021-07-26 12:05:45,368 fail2ban.filtersystemd [83683]: INFO [dovecot] Added journal match for: ‘_SYSTEMD_UNIT=dovecot.service’
2021-07-26 12:05:45,368 fail2ban.filter [83683]: INFO maxRetry: 5
2021-07-26 12:05:45,369 fail2ban.filter [83683]: INFO findtime: 86400
2021-07-26 12:05:45,369 fail2ban.actions [83683]: INFO banTime: 86400
2021-07-26 12:05:45,369 fail2ban.filter [83683]: INFO encoding: UTF-8
2021-07-26 12:05:45,369 fail2ban.jail [83683]: INFO Creating new jail ‘postfix-sasl’
2021-07-26 12:05:45,369 fail2ban.jail [83683]: INFO Jail ‘postfix-sasl’ uses systemd {}
2021-07-26 12:05:45,370 fail2ban.jail [83683]: INFO Initiated ‘systemd’ backend
2021-07-26 12:05:45,373 fail2ban.filtersystemd [83683]: INFO [postfix-sasl] Added journal match for: ‘_SYSTEMD_UNIT=postfix.service’
2021-07-26 12:05:45,373 fail2ban.filter [83683]: INFO maxRetry: 3
2021-07-26 12:05:45,373 fail2ban.filter [83683]: INFO findtime: 86400
2021-07-26 12:05:45,373 fail2ban.actions [83683]: INFO banTime: 604800
2021-07-26 12:05:45,374 fail2ban.filter [83683]: INFO encoding: UTF-8
2021-07-26 12:05:45,378 fail2ban.jail [83683]: INFO Jail ‘sshd’ started
2021-07-26 12:05:45,379 fail2ban.filtersystemd [83683]: NOTICE Jail started without ‘journalmatch’ set. Jail regexs will be checked against all journal entries, which is not advised for performance reasons.
2021-07-26 12:05:45,382 fail2ban.jail [83683]: INFO Jail ‘x-ban’ started
2021-07-26 12:05:45,383 fail2ban.jail [83683]: INFO Jail ‘dovecot’ started
2021-07-26 12:05:45,385 fail2ban.jail [83683]: INFO Jail ‘postfix-sasl’ started
Merci