@@ -45,7 +45,12 @@ in
4545 enable = mkOption {
4646 default = false;
4747 type = types.bool;
48− description = "Whether to enable the fail2ban service.";
48+ description = ''
49+ Whether to enable the fail2ban service.
50+
51+ See the documentation of <option>services.fail2ban.jails</option>
52+ for what jails are enabled by default.
53+ '';
4954 };
5055
5156 package = mkOption {
@@ -221,6 +226,15 @@ in
221226 defined in <filename>/etc/fail2ban/action.d</filename>,
222227 while filters are defined in
223228 <filename>/etc/fail2ban/filter.d</filename>.
229+
230+ NixOS comes with a default <literal>sshd</literal> jail;
231+ for it to work well,
232+ <option>services.openssh.logLevel</option> should be set to
233+ <literal>"VERBOSE"</literal> or higher so that fail2ban
234+ can observe failed login attempts.
235+ This module sets it to <literal>"VERBOSE"</literal> if
236+ not set otherwise, so enabling fail2ban can make SSH logs
237+ more verbose.
224238 '';
225239 };
226240
@@ -313,6 +327,9 @@ in
313327 banaction_allports = ${cfg.banaction-allports}
314328 '';
315329 # Block SSH if there are too many failing connection attempts.
330+ # Benefits from verbose sshd logging to observe failed login attempts,
331+ # so we set that here unless the user overrode it.
332+ services.openssh.logLevel = lib.mkDefault "VERBOSE";
316333 services.fail2ban.jails.sshd = mkDefault ''
317334 enabled = true
318335 port = ${concatMapStringsSep "," (p: toString p) config.services.openssh.ports}