Sorry for the confusion…
Ubuntu 22.04 is less restrictive - by default - it allows 5 attempts before banning, on Stretch it’s 3 - and once I got it working on Bookworm - also 3…
Of my steps - to get it working on Bookworm :
Copied the default conf (exactly the same as what @Rosika did). My only jail is called “sshd”.
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
Then I had to run fail2ban-client to get it work.
sudo fail2ban-client -vv start
Then I restarted fail2ban (systemd daemon) and it worked.
sudo systemctl start fail2ban
I tested banning my IP address on both the Pi4 running bunty 22, and Pi5 running bookworm… allows 5 failed attempts on bunty, and 3 failed attempts on bookworm, before banning… easy enough to unban :
sudo fail2ban-client set sshd unbanip x.x.x.x