feat(systems/optional/services; vars): add vars/networking, add openssh

This commit is contained in:
madmin 2024-08-09 10:53:24 +02:00
parent dd35e66698
commit b86fa030ec
3 changed files with 48 additions and 2 deletions

View File

@ -0,0 +1,42 @@
{ lib, config, configVars, ... }:
let
sshPort = configVars.networking.sshPort;
# Sops needs access to the keys before the persist dirs are even mounted; so
# just persisting the keys won't work, we must point at /persist
hasOptinPersistence = false;
in
{
services.openssh = {
enable = true;
ports = [ sshPort ];
settings = {
# Harden
PasswordAuthentication = false;
PermitRootLogin = "no";
# Automatically remove stale sockets
StreamLocalBindUnlink = "yes";
# Allow forwarding ports to everywhere
GatewayPorts = "clientspecified";
};
hostKeys = [{
path = "${lib.optionalString hasOptinPersistence "/persist"}/etc/ssh/ssh_host_ed25519_key";
type = "ed25519";
}];
# Fix LPE vulnerability with sudo use SSH_AUTH_SOCK: https://github.com/NixOS/nixpkgs/issues/31611
authorizedKeysFiles = lib.mkForce [ "/etc/ssh/authorized_keys.d/%u" ];
};
# yubikey login / sudo
# this potentially causes a security issue that we mitigated above
security.pam = {
sshAgentAuth.enable = true;
services = {
sudo.u2fAuth = true;
};
};
networking.firewall.allowedTCPPorts = [ sshPort ];
}

View File

@ -1,9 +1,11 @@
{ inputs, lib }: { inputs, lib }:
{ {
networking = import ./networking.nix { inherit lib; };
username = "laozi"; username = "laozi";
#domain = inputs.nix-secrets.domain; #domain = inputs.nix-secrets.domain;
#userFullName = inputs.nix-secrets.full-name; #userFullName = inputs.nix-secrets.full-name;
#handle = "madmin"; handle = "madmin";
#userEmail = inputs.nix-secrets.user-email; #userEmail = inputs.nix-secrets.user-email;
#gitEmail = "madmin@noreply.codeberg.org"; #gitEmail = "madmin@noreply.codeberg.org";
#workEmail = inputs.nix-secrets.work-email; #workEmail = inputs.nix-secrets.work-email;

View File

@ -1,2 +1,4 @@
{ ... }: { ... }:
{} {
sshPort = 22;
}