2023-03-20 01:37:46 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
format,
|
|
|
|
...
|
2024-08-03 17:32:02 +00:00
|
|
|
}: let
|
|
|
|
inherit (lib) mkIf mkEnableOption mkOption mkDefault types;
|
2023-03-20 01:37:46 +00:00
|
|
|
|
2024-08-03 17:32:02 +00:00
|
|
|
cfg = config.aa.services.openssh;
|
2023-03-20 01:37:46 +00:00
|
|
|
default-key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEmPdQcM0KCQ3YunF1gwN+B+i1Q8KrIfiUvNtgFQjTy2";
|
|
|
|
in {
|
2024-08-03 17:32:02 +00:00
|
|
|
options.aa.services.openssh = {
|
2023-03-20 01:37:46 +00:00
|
|
|
enable = mkEnableOption "ssh";
|
|
|
|
authorizedKeys = mkOption {
|
2024-08-03 17:32:02 +00:00
|
|
|
type = types.listOf types.str;
|
2023-03-20 01:37:46 +00:00
|
|
|
default = [default-key];
|
|
|
|
description = "The public keys to authorize";
|
|
|
|
};
|
2023-04-16 17:07:42 +00:00
|
|
|
};
|
2023-03-20 01:37:46 +00:00
|
|
|
|
2023-04-16 17:07:42 +00:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
PasswordAuthentication = false;
|
|
|
|
PermitRootLogin = mkDefault (
|
|
|
|
if format == "install-iso"
|
|
|
|
then "yes"
|
|
|
|
else "no"
|
|
|
|
);
|
2023-03-20 01:37:46 +00:00
|
|
|
};
|
2023-04-16 17:07:42 +00:00
|
|
|
};
|
2023-03-20 01:37:46 +00:00
|
|
|
|
2023-04-16 17:07:42 +00:00
|
|
|
aa.user.extraOptions = {
|
|
|
|
openssh.authorizedKeys.keys = cfg.authorizedKeys;
|
2023-03-20 01:37:46 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|