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