nix-stuff/roles/server/ssh.nix

46 lines
1.1 KiB
Nix
Executable file

{
flakeSelf,
config,
...
}: let
hostSecrets = "${flakeSelf.inputs.secrets}/" + config.networking.hostName + "/";
hostKeyPath = "/etc/ssh/everest_host_key";
in {
age.secrets = {
everest-host-key = {
file = hostSecrets + "host-private-key.age";
path = hostKeyPath;
mode = "0400";
};
"everest-host-key.pub" = {
file = hostSecrets + "host-public-key.age";
path = hostKeyPath + ".pub";
};
};
users.users.toast.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEas0RvecJpUA1rG87fHunxDb4O0Q7bQG7X8h3hZnrsE Everest access key"
];
services.openssh = {
enable = true;
settings = {
UseDns = true;
PermitRootLogin = "no";
PasswordAuthentication = false;
};
# The forgejo module is fucky so I can't set this with the nixos option
# https://github.com/NixOS/nixpkgs/issues/306205
extraConfig = ''
AcceptEnv COLORTERM
'';
hostKeys = [
{
path = hostKeyPath;
type = "ed25519";
comment = "Everest host key";
}
];
startWhenNeeded = true;
};
}