fix(ssh): further harden SSH

This commit is contained in:
hektor committed 2026-10-25 17:37:20 +01:00
1 parent 432a4c107a
commit 445bdde2dc
1 file changed
+26 -12
+26 -12
View File
@@ -17,18 +17,32 @@ in
config = {
networking.firewall.allowedTCPPorts = lib.mkIf config.ssh.enable [ 22 ];
services.openssh.settings = optionalAttrs cfg.harden {
PermitRootLogin = "no";
PasswordAuthentication = false;
AuthenticationMethods = "publickey";
KbdInteractiveAuthentication = false;
ChallengeResponseAuthentication = false;
X11Forwarding = false;
AllowAgentForwarding = false;
AllowTcpForwarding = false;
PermitTunnel = false;
MaxAuthTries = 3;
LoginGraceTime = "1m";
services.openssh = {
settings = optionalAttrs cfg.harden {
PermitRootLogin = "no";
PasswordAuthentication = false;
AuthenticationMethods = "publickey";
KbdInteractiveAuthentication = false;
ChallengeResponseAuthentication = false;
X11Forwarding = false;
AllowAgentForwarding = false;
AllowTcpForwarding = false;
PermitTunnel = false;
MaxAuthTries = 3;
LoginGraceTime = "1m";
ClientAliveInterval = 300;
ClientAliveCountMax = 2;
TCPKeepAlive = false;
MaxSessions = 4;
LogLevel = "VERBOSE";
AllowUsers = [ config.host.username ];
};
hostKeys = mkIf cfg.harden [
{
type = "ed25519";
path = "/etc/ssh/ssh_host_ed25519_key";
}
];
};
};
}