From 01cc32ee50b89cc86185b14c9ad3bb9c08781784 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Mon, 9 Nov 2026 20:47:55 -0500 Subject: [PATCH] dedupe ssh config --- modules/common/ssh.nix | 17 +++++++++++++++++ modules/mobile/ssh.nix | 13 +------------ modules/server/ssh.nix | 29 +---------------------------- 3 files changed, 19 insertions(+), 40 deletions(-) create mode 100644 modules/common/ssh.nix diff --git a/modules/common/ssh.nix b/modules/common/ssh.nix new file mode 100644 index 0000000..95a071d --- /dev/null +++ b/modules/common/ssh.nix @@ -0,0 +1,17 @@ +{ config, lib, ... }: +{ + options.quad.ssh.enable = lib.mkEnableOption "the SSH server, with key-only login as quadradical"; + + config = lib.mkIf config.quad.ssh.enable { + users.users.quadradical.openssh.authorizedKeys.keys = import ../../secrets/keys.nix; + services.openssh = { + enable = true; + openFirewall = true; + settings = { + PasswordAuthentication = false; + AllowUsers = [ "quadradical" ]; + PermitRootLogin = "no"; + }; + }; + }; +} diff --git a/modules/mobile/ssh.nix b/modules/mobile/ssh.nix index db30bac..71ab191 100644 --- a/modules/mobile/ssh.nix +++ b/modules/mobile/ssh.nix @@ -1,12 +1 @@ -{ - users.users.quadradical.openssh.authorizedKeys.keys = import ../../secrets/keys.nix; - services.openssh = { - enable = true; - openFirewall = true; - settings = { - PasswordAuthentication = false; - AllowUsers = [ "quadradical" ]; - PermitRootLogin = "no"; - }; - }; -} +{ quad.ssh.enable = true; } diff --git a/modules/server/ssh.nix b/modules/server/ssh.nix index 7899f3b..71ab191 100644 --- a/modules/server/ssh.nix +++ b/modules/server/ssh.nix @@ -1,28 +1 @@ -{ - users.users.quadradical.openssh.authorizedKeys.keys = import ../../secrets/keys.nix; - services = { - openssh = { - enable = true; - openFirewall = true; - settings = { - PasswordAuthentication = false; - AllowUsers = [ "quadradical" ]; - PermitRootLogin = "no"; - }; - }; - - fail2ban = { - enable = true; - maxretry = 5; - ignoreIP = [ "192.168.0.0/16" ]; - bantime = "6h"; - bantime-increment = { - enable = true; - formula = "ban.Time * math.exp(float(ban.Count+1)*banFactor)/math.exp(1*banFactor)"; - maxtime = "240h"; - overalljails = true; - }; - }; - }; - -} +{ quad.ssh.enable = true; }