hosts: add pubkeys for $host-hn
This commit is contained in:
parent
f9091c0b0c
commit
a49abbd123
|
@ -1,13 +1,17 @@
|
|||
{ config, lib, sane-lib, ... }:
|
||||
|
||||
let
|
||||
keysForHost = hostName: let
|
||||
hostCfg = config.sane.hosts.by-name."${hostName}";
|
||||
in {
|
||||
"root@${hostName}" = hostCfg.ssh.host_pubkey;
|
||||
"colin@${hostName}" = lib.mkIf (hostCfg.ssh.user_pubkey != null && hostCfg.ssh.authorized) hostCfg.ssh.user_pubkey;
|
||||
};
|
||||
hostKeys = builtins.map keysForHost (builtins.attrNames config.sane.hosts.by-name);
|
||||
hostKeys = lib.mapAttrsToList
|
||||
(hostName: hostCfg:
|
||||
# generate `root@servo`, `colin@servo`, `root@servo-hn`, `colin@servo-hn`, ... as a single attrset:
|
||||
lib.foldl' (acc: alias: acc // {
|
||||
"root@${alias}" = hostCfg.ssh.host_pubkey;
|
||||
"colin@${alias}" = lib.mkIf (hostCfg.ssh.user_pubkey != null && hostCfg.ssh.authorized) hostCfg.ssh.user_pubkey;
|
||||
})
|
||||
{}
|
||||
hostCfg.names
|
||||
)
|
||||
config.sane.hosts.by-name;
|
||||
in
|
||||
{
|
||||
sane.ssh.pubkeys = lib.mkMerge (hostKeys ++ [
|
||||
|
|
Loading…
Reference in New Issue
Block a user