ssh options

This commit is contained in:
John Lancaster
2026-03-29 16:53:54 -05:00
parent 0cf3f05df2
commit e0abbd6b90
2 changed files with 13 additions and 16 deletions
+1
View File
@@ -0,0 +1 @@
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNpgz9xYE3K+JeQ7vtDA07iWlp0xTXB+G8MBzX6/RluXs8E6v+ahx90M093EYIOImaW6npWQ0JnFtmZaet5l9Ao=
+13 -16
View File
@@ -1,35 +1,32 @@
{inputs, ... }:
{ inputs, ... }:
let
userName = "john";
sshHostCAPubKey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNug18oLH0vZxnibXJzMJvTWFPZTnSlhCDDVi+rHhgnIum6ZXQ4SF+VHOOAM5BbzZmMKitNJ5lcrGP15Eur7DzQ=";
in
{
flake.modules.nixos.ssh = { pkgs, config, lib, ... }:
flake.modules.nixos.ssh = { config, pkgs, lib, ... }:
let
cfg = config.ssh;
userCAPath = "ssh/ssh_user_ca.pub";
configDir = "/etc/ssh";
in
{
options.ssh = {
configDir = lib.mkOption {
description = "String path to the host SSH config directory";
type = lib.types.str;
default = "/etc/ssh";
};
hostKey = lib.mkOption {
description = "String path to the host private key file";
type = lib.types.str;
default = "${cfg.configDir}/ssh_host_ed25519_key";
default = "ssh_host_ed25519_key";
};
certificates = {
enable = lib.mkEnableOption "Enable SSH host certificates";
userCA = lib.mkOption {
description = "Content for the SSH user CA file (public key)";
type = lib.types.path;
default = ../../keys/ssh_user_ca.pub;
default = ../hosts/janus/ssh_user_ca.pub;
};
userCAPath = lib.mkOption {
userCAFile = lib.mkOption {
description = "String path to the SSh user CA";
type = lib.types.str;
default = "${cfg.configDir}/ssh_user_ca.pub";
default = "ssh_user_ca.pub";
};
};
};
@@ -42,16 +39,16 @@ in
{
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
HostKey = cfg.hostKey;
HostKey = "${configDir}/${cfg.hostKey}";
}
(lib.mkIf cfg.certificates.enable {
TrustedUserCAKeys = cfg.certificates.userCAPath;
HostCertificate = "${cfg.hostKey}-cert.pub";
TrustedUserCAKeys = "${configDir}/${cfg.certificates.userCAFile}";
HostCertificate = "${configDir}/${cfg.hostKey}-cert.pub";
})
];
};
environment.etc."${userCAPath}" = lib.mkIf cfg.certificates.enable {
environment.etc."ssh/${cfg.certificates.userCAFile}" = lib.mkIf cfg.certificates.enable {
source = cfg.certificates.userCA;
};