blob: 36b85f8f0d98ba4d32952f47462470afb3d4b319 (
plain) (
blame)
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
|
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.nixfiles.modules.openssh;
in {
options.nixfiles.modules.openssh.server = {
enable = mkEnableOption "OpenSSH server";
port = mkOption {
description = "OpenSSH server port.";
type = types.port;
default = 22022; # Port 22 should be occupied by a tarpit.
};
};
config = mkIf cfg.server.enable {
programs.mosh.enable = true;
services = {
openssh = {
enable = true;
ports = [cfg.server.port];
logLevel = "VERBOSE"; # Required by fail2ban.
permitRootLogin = mkForce "no";
passwordAuthentication = false;
};
fail2ban.jails.sshd = ''
enabled = true
mode = aggressive
port = ${toString cfg.server.port}
'';
};
};
}
|