@@ -1,12 +1,13 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
paths,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (config.host) username;
|
||||
adminHosts = (import ../../utils { inherit lib; }).adminHosts ../../hosts;
|
||||
adminHosts = (import ../../utils { inherit lib; }).adminHosts paths.hosts;
|
||||
in
|
||||
{
|
||||
options.ssh = {
|
||||
@@ -22,7 +23,7 @@ in
|
||||
map (
|
||||
hostname:
|
||||
let
|
||||
keyFile = ../../hosts/${hostname}/ssh_user.pub;
|
||||
keyFile = paths.hosts + "/${hostname}/ssh_user.pub";
|
||||
in
|
||||
lib.optionals (builtins.pathExists keyFile) (lib.splitString "\n" (builtins.readFile keyFile))
|
||||
) ((builtins.filter (h: h != config.host.name) adminHosts) ++ config.ssh.authorizedHosts)
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
lib,
|
||||
config,
|
||||
outputs,
|
||||
paths,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
hosts = lib.attrNames outputs.nixosConfigurations;
|
||||
hostsWithKeys = lib.filter (
|
||||
hostname: builtins.pathExists ../../hosts/${hostname}/ssh_host.pub
|
||||
) hosts;
|
||||
keyPath = hostname: paths.hosts + "/${hostname}/ssh_host.pub";
|
||||
hostsWithKeys = lib.filter (hostname: builtins.pathExists (keyPath hostname)) hosts;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf config.ssh.enable {
|
||||
programs.ssh.knownHosts = lib.genAttrs hostsWithKeys (hostname: {
|
||||
publicKeyFile = ../../hosts/${hostname}/ssh_host.pub;
|
||||
publicKeyFile = keyPath hostname;
|
||||
extraHostNames = lib.optional (hostname == config.networking.hostName) "localhost";
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user