I have a rule like this in my jail.local file:


enabled = true
port    = ssh,sftp
filter  = sshd-ddos
logpath  = /var/log/messages
maxretry = 4

If I want to use a custom port for SSH, does Fail2ban automatically infer it from my sshd_config file or should I specify the port numerically?


You must specify the custom port in the [ssh] section, something like this:

  • Thanks, wanted to double check. Thought it might read the sshd_config (that'd be sweet). – Trent Scott Oct 3 '11 at 0:24
  • It reads /etc/services for standard port names. – Selivanov Pavel Dec 6 '11 at 22:30
  • This is completely valid while I have a custom sshd.xml file under /etc/firewalld/services with the custom port of sshd. firewalld and selinux are completely ok with my setup; but "fail2ban fails 2 ban" --Thanks :) – Achilles Oct 8 '17 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.