feat: automate SSH config ('known_hosts', 'authorized_keys' ...)
This commit is contained in:
25
home/modules/ssh.nix
Normal file
25
home/modules/ssh.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
outputs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
nixosConfigs = builtins.attrNames outputs.nixosConfigurations;
|
||||
homeConfigs = map (n: lib.last (lib.splitString "@" n)) (
|
||||
builtins.attrNames outputs.homeConfigurations
|
||||
);
|
||||
allHosts = lib.unique (homeConfigs ++ nixosConfigs);
|
||||
hostsWithKeys = lib.filter (
|
||||
hostname: builtins.pathExists ../../hosts/${hostname}/ssh_host.pub
|
||||
) allHosts;
|
||||
in
|
||||
{
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
|
||||
matchBlocks = lib.genAttrs hostsWithKeys (hostname: {
|
||||
host = hostname;
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user