flake/modules/services/openssh.nix
2025-09-16 11:08:21 +03:00

39 lines
865 B
Nix

{
config,
lib,
...
}:
{
options = {
myModules.enableOpenssh = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable OpenSSH service";
};
};
config = lib.mkMerge [
(lib.mkIf config.myModules.enableOpenssh {
services.openssh = {
enable = true;
startWhenNeeded = true;
settings = {
PermitRootLogin = "no";
# only allow key based logins and not password
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
AuthenticationMethods = "publickey";
PubkeyAuthentication = "yes";
ChallengeResponseAuthentication = "no";
UsePAM = false;
# kick out inactive sessions
ClientAliveCountMax = 5;
ClientAliveInterval = 60;
};
};
})
];
}