nixos/hosts/common/optional/openssh.nix

34 lines
772 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-23 10:48:00 +01:00
programs.ssh.extraConfig = ''
Host git.bitlab21.com
IdentitiesOnly yes
StrictHostKeyChecking no
IdentityFile /etc/ssh/deploy_key-ssh-ed25519
'';
2024-05-12 19:58:55 +01:00
networking.firewall.allowedTCPPorts = [ sshPort ];
}