Modularize NixOS SSH config

main
Hektor Misplon 2025-11-10 17:04:45 +01:00
parent e92d5c0da9
commit 1c4b3be339
2 changed files with 21 additions and 21 deletions

View File

@ -14,6 +14,7 @@
../../modules/localization.nix ../../modules/localization.nix
../../modules/x.nix ../../modules/x.nix
../../modules/fonts ../../modules/fonts
../../modules/ssh/hardened-openssh.nix
]; ];
nix.settings.experimental-features = [ nix.settings.experimental-features = [
@ -52,26 +53,6 @@
services.openssh = { services.openssh = {
enable = true; enable = true;
startWhenNeeded = true; harden = true;
settings = {
## hardening
PermitRootLogin = "no";
MaxAuthTries = 3;
LoginGraceTime = "1m";
PasswordAuthentication = false;
PermitEmptyPasswords = false;
ChallengeResponseAuthentication = false;
KerberosAuthentication = false;
GSSAPIAuthentication = false;
X11Forwarding = false;
PermitUserEnvironment = false;
AllowAgentForwarding = false;
AllowTcpForwarding = false;
PermitTunnel = false;
## sshd_config defaults on Arch Linux
KbdInteractiveAuthentication = false;
UsePAM = true;
PrintMotd = false;
};
}; };
} }

View File

@ -0,0 +1,19 @@
{ lib, config, ... }:
with lib;
let
cfg = config.services.openssh;
in
{
options.services.openssh.harden = mkEnableOption "harden ssh server configuration";
config.services.openssh.settings = optionalAttrs cfg.harden {
PermitRootLogin = "no";
PasswordAuthentication = false;
ChallengeResponseAuthentication = false;
X11Forwarding = false;
AllowAgentForwarding = false;
AllowTcpForwarding = false;
PermitTunnel = false;
MaxAuthTries = 3;
LoginGraceTime = "1m";
};
}