nixos/hosts/common/optional/openssh.nix

28 lines
594 B
Nix
Raw Normal View History

2024-05-12 19:58:55 +01:00
{ lib, config, ... }:
let
sshPort = 22;
in
{
services.openssh = {
enable = true;
ports = [ sshPort ];
2024-05-22 17:23:17 +01:00
authorizedKeysFiles = lib.mkForce ["/etc/ssh/authorized_keys.d/%u"];
hostKeys = [{
path = "/persist/etc/ssh/ssh_host_ed25519_key";
type = "ed25519";
}];
2024-05-12 19:58:55 +01:00
settings = {
2024-05-22 17:23:17 +01:00
PasswordAuthentication = false;
2024-05-12 19:58:55 +01:00
PermitRootLogin = "no";
2024-05-22 17:23:17 +01:00
PubKeyAuthentication = "yes";
2024-05-12 19:58:55 +01:00
StreamLocalBindUnlink = "yes";
2024-05-22 17:23:17 +01:00
UsePAM = true;
2024-05-12 19:58:55 +01:00
};
};
2024-05-22 17:23:17 +01:00
security.pam = {
sshAgentAuth.enable = true;
};
2024-05-12 19:58:55 +01:00
networking.firewall.allowedTCPPorts = [ sshPort ];
}