feat: automate SSH config ('known_hosts', 'authorized_keys' ...)
This commit is contained in:
19
modules/ssh/known-hosts.nix
Normal file
19
modules/ssh/known-hosts.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
outputs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hosts = lib.attrNames outputs.nixosConfigurations;
|
||||
hostsWithKeys = lib.filter (
|
||||
hostname: builtins.pathExists ../../hosts/${hostname}/ssh_host.pub
|
||||
) hosts;
|
||||
in
|
||||
{
|
||||
# auto generate known_hosts for all hosts in flake
|
||||
programs.ssh.knownHosts = lib.genAttrs hostsWithKeys (hostname: {
|
||||
publicKeyFile = ../../hosts/${hostname}/ssh_host.pub;
|
||||
extraHostNames = lib.optional (hostname == config.networking.hostName) "localhost";
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user