2022-09-20 11:50:45 +00:00
|
|
|
{ config, pkgs, lib, ... }: {
|
|
|
|
|
|
|
|
options = {
|
|
|
|
publicKey = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Public SSH key authorized for this system.";
|
|
|
|
};
|
2022-09-20 12:50:04 +00:00
|
|
|
permitRootLogin = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Root login settings.";
|
|
|
|
default = "no";
|
|
|
|
};
|
2022-09-20 11:50:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
ports = [ 22 ];
|
|
|
|
passwordAuthentication = false;
|
|
|
|
gatewayPorts = "no";
|
|
|
|
forwardX11 = false;
|
|
|
|
allowSFTP = true;
|
2022-09-20 12:50:04 +00:00
|
|
|
permitRootLogin = config.permitRootLogin;
|
2022-09-20 11:50:45 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 12:50:04 +00:00
|
|
|
users.users.${config.user}.openssh.authorizedKeys.keys =
|
|
|
|
[ config.publicKey ];
|
2022-09-20 11:50:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|