Bonjour,
J’ai installé avec succès Ynohost ce week-end.
Bravo pour ce travail qui permet en quelques clics d’installer de nombreux outils qui demandent beaucoup de temps normalement à paramétrer…
J’ai vu dans mes logs qu’il y a de nombreuses attaques SSH et je ne comprends pas pourquoi fail2ban ne les bannit pas :
--------------------- pam_unix Begin ------------------------
J’ai ajouté dans /etc/fail2ban/jail.d/fred.conf mais cela ne fonctionne pas mieux.
[DEFAULT]
# 1 jour de bannissement quel que soit le plugin
bantime = 86400
# ajouter son adresse ip ici pour ne pas se faire bannir quand on se connecte
# adresses ip separees par un espace
ignoreip = 127.0.0.1/8 192.168.2.3
# le destinataire des mails de notifications
destemail = monmail
# l'expediteur du message
sender = root
# le nombre d essais maximum avant bannissement
maxretry = 2
# type d envoi pour les notifications (w = whois)
#action = %(action_mw)s
# ou mail-buffered (ban & send an e-mail with buffered report to the destemail)
# Envoi quand il y a 10 ip bloquées pour limiter les notifications
action_mb = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-buffered[name=%(__name__)s, sender="%(sender)s", dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s", lines=10]
action = %(action_mb)s
En complément de mon message :
==> /var/log/auth.log
Jan 28 10:59:22 yuno sshd[24921]: PAM 1 more authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.242.83.38 user=root
Jan 28 11:00:01 yuno CRON[24930]: pam_unix(cron:session): session opened for user nextcloud by (uid=0)
Jan 28 11:00:05 yuno CRON[24930]: pam_unix(cron:session): session closed for user nextcloud
Jan 28 11:01:03 yuno sshd[24963]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.242.83.38 user=root
Jan 28 11:01:05 yuno sshd[24963]: Failed password for root from 58.242.83.38 port 23266 ssh2
Jan 28 11:01:08 yuno sshd[24963]: Failed password for root from 58.242.83.38 port 23266 ssh2
Jan 28 11:01:10 yuno sshd[24963]: Failed password for root from 58.242.83.38 port 23266 ssh2
Jan 28 11:01:10 yuno sshd[24963]: Received disconnect from 58.242.83.38 port 23266:11: [preauth]
Jan 28 11:01:10 yuno sshd[24963]: Disconnected from 58.242.83.38 port 23266 [preauth]
Jan 28 11:01:10 yuno sshd[24963]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.242.83.38 user=root
Jan 28 11:01:59 yuno sshd[24974]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.242.83.38 user=root
Jan 28 11:02:01 yuno sshd[24974]: Failed password for root from 58.242.83.38 port 57424 ssh2
Jan 28 11:02:03 yuno sshd[24974]: Failed password for root from 58.242.83.38 port 57424 ssh2
Jan 28 11:02:06 yuno sshd[24974]: Failed password for root from 58.242.83.38 port 57424 ssh2
Jan 28 11:02:06 yuno sshd[24974]: Received disconnect from 58.242.83.38 port 57424:11: [preauth]
Jan 28 11:02:06 yuno sshd[24974]: Disconnected from 58.242.83.38 port 57424 [preauth]
Jan 28 11:02:06 yuno sshd[24974]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.242.83.38 user=root
et
fail2ban-client status
Status
|- Number of jail: 11
`- Jail list: dovecot, etherpad_mypads, nginx-http-auth, pam-generic, postfix, postfix-sasl, recidive, sshd, sshd-ddos, wordpress, yunohost
2019-01-29 21:24:16,937 fail2ban.jail [27922]: INFO Jail ‘sshd’ started
2019-01-29 21:24:16,948 fail2ban.jail [27922]: INFO Jail ‘sshd-ddos’ started
2019-01-29 21:24:16,955 fail2ban.jail [27922]: INFO Jail ‘nginx-http-auth’ started
2019-01-29 21:24:16,962 fail2ban.jail [27922]: INFO Jail ‘postfix’ started
2019-01-29 21:24:16,968 fail2ban.jail [27922]: INFO Jail ‘dovecot’ started
2019-01-29 21:24:16,973 fail2ban.jail [27922]: INFO Jail ‘postfix-sasl’ started
2019-01-29 21:24:16,980 fail2ban.jail [27922]: INFO Jail ‘recidive’ started
2019-01-29 21:24:17,027 fail2ban.jail [27922]: INFO Jail ‘pam-generic’ started
2019-01-29 21:24:17,099 fail2ban.jail [27922]: INFO Jail ‘etherpad_mypads’ started
2019-01-29 21:24:17,110 fail2ban.jail [27922]: INFO Jail ‘wordpress’ started
2019-01-29 21:24:17,119 fail2ban.jail [27922]: INFO Jail ‘yunohost’ started
naivement, est-ce que tu peux t’assurer que la conf fail2ban est à jour avec yunohost service regen-conf fail2ban ? (mais j’imagine que oui) J’imagine que tu t’es aussi assuré que fail2ban tourne ?
Merci de tes réponses Aleks. yunohost service regen-conf fail2ban -> ne renvoie rien donc ok
Pour le test de la jail, j’ai l’habitude de lancer :
‘fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf –v’
et cela me donne :
Lines: 29845 lines, 0 ignored, 14606 matched, 15239 missed
Je ne comprends pas ce qui se passe. ça matched mais pas de ban ;((