aboutsummaryrefslogtreecommitdiff
path: root/modules/nixos/server/openssh/default.nix
blob: a56460d7cce2fe7ad70edaa2b22714cfbfa515d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
  config,
  lib,
  ...
}:

let
  inherit (lib) mkEnableOption mkIf;
  cfg = config.nx.server.openssh;
in
{
  options.nx.server.openssh = {
    enable = mkEnableOption "OpenSSH server";
  };

  config = mkIf cfg.enable {
    services.openssh = {
      enable = true;
      ports = [ 8693 ];
      settings = {
        PasswordAuthentication = false;
        AllowUsers = [ ];
        X11Forwarding = false;
        PermitRootLogin = "yes";
      };
    };
    networking.firewall.allowedTCPPorts = [ 8693 ];

    services.fail2ban = {
      enable = true;
      bantime = "1h";
      jails = {
        sshd = {
          enabled = true;
          settings = {
            port = 8693;
            backend = "systemd";
            maxretry = 4;
            findtime = "10m";
          };
        };
      };
    };
  };
}