Skip to content

Commit

Permalink
ssh: add extraConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
kloenk committed Jan 30, 2024
1 parent 91b9daf commit eb70090
Showing 1 changed file with 45 additions and 18 deletions.
63 changes: 45 additions & 18 deletions modules/programs/ssh/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,44 @@ in
'';
};

programs.ssh.knownHosts = mkOption {
default = {};
type = types.attrsOf (types.submodule host);
description = lib.mdDoc ''
The set of system-wide known SSH hosts.
'';
example = literalExpression ''
[
{
hostNames = [ "myhost" "myhost.mydomain.com" "10.10.1.4" ];
publicKeyFile = ./pubkeys/myhost_ssh_host_dsa_key.pub;
}
{
hostNames = [ "myhost2" ];
publicKeyFile = ./pubkeys/myhost2_ssh_host_dsa_key.pub;
}
]
'';
programs.ssh = {
knownHosts = mkOption {
default = {};
type = types.attrsOf (types.submodule host);
description = lib.mdDoc ''
The set of system-wide known SSH hosts.
'';
example = literalExpression ''
[
{
hostNames = [ "myhost" "myhost.mydomain.com" "10.10.1.4" ];
publicKeyFile = ./pubkeys/myhost_ssh_host_dsa_key.pub;
}
{
hostNames = [ "myhost2" ];
publicKeyFile = ./pubkeys/myhost2_ssh_host_dsa_key.pub;
}
]
'';
};

pubkeyAcceptedKeyTypes = mkOption {
type = types.listOf types.str;
default = [];
example = [ "ssh-ed25519" "ssh-rsa" ];
description = lib.mdDoc ''
Specifies the key types that will be used for public key authentication.
'';
};

extraConfig = mkOption {
type = types.lines;
default = "";
description = lib.mdDoc ''
Extra configuration text written to `/etc/ssh/ssh_config.d/10-extra-nix.conf`.
See {manpage}`ssh_config(5)` for help.
'';
};
};
};

Expand All @@ -163,6 +183,13 @@ in
# Allows us to automatically migrate from using a file to a symlink
knownSha256Hashes = [ oldAuthorizedKeysHash ];
};
"ssh/sshd_config.d/10-extra-nix.conf" = {
text = ''
${optionalString (cfg.pubkeyAcceptedKeyTypes != []) "PubkeyAcceptedKeyTypes ${concatStringsSep "," cfg.pubkeyAcceptedKeyTypes}"}
${config.programs.ssh.extraConfig}
'';
};
};

# Clean up .before-nix-darwin file left over from using knownSha256Hashes
Expand Down

0 comments on commit eb70090

Please sign in to comment.