extra principals for SSH host certs
This commit is contained in:
@@ -5,6 +5,12 @@
|
||||
provisionerPasswordPath = config.sops.secrets."janus/admin_jwk".path;
|
||||
sshKeyPath = "/etc/ssh/ssh_host_ed25519_key";
|
||||
sshCertPath = "${sshKeyPath}-cert.pub";
|
||||
mkPrincipalArgs = principals:
|
||||
lib.concatMapStringsSep " " (principal: ''--principal "${principal}"'') principals;
|
||||
principalArgs = mkPrincipalArgs ([
|
||||
cfg.hostname
|
||||
"${cfg.hostname}.john-stream.com"
|
||||
] ++ cfg.extraPrincipals);
|
||||
in
|
||||
{
|
||||
# NixOS Options
|
||||
@@ -18,6 +24,11 @@
|
||||
type = lib.types.str;
|
||||
default = "admin";
|
||||
};
|
||||
extraPrincipals = lib.mkOption {
|
||||
description = "Additional SSH host certificate principals to include per host";
|
||||
type = with lib.types; listOf str;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
imports = with inputs.self.modules.nixos; [ ssh ];
|
||||
@@ -39,8 +50,7 @@
|
||||
--host --sign \
|
||||
--provisioner "${cfg.provisioner}" \
|
||||
--provisioner-password-file "${provisionerPasswordPath}" \
|
||||
--principal "${cfg.hostname}" \
|
||||
--principal "${cfg.hostname}.john-stream.com" \
|
||||
${principalArgs} \
|
||||
"${cfg.hostname}" "${sshKeyPath}.pub"
|
||||
'')
|
||||
(writeShellScriptBin "ssh-host-cert-check" "${lib.getExe' pkgs.openssh "ssh-keygen"} -Lf ${sshCertPath}")
|
||||
|
||||
Reference in New Issue
Block a user