Files
nixos-configuration/shared/base/modules/security/ssh.nix

25 lines
603 B
Nix

# /nix/store/<hash>/etc/ssh/ssh_config & /nix/store/<hash>/etc/ssh/authorized_keys
{
lib,
systemConfig,
systems,
common,
...
}:
{
programs.ssh.knownHosts = builtins.mapAttrs (hostName: system: {
extraHostNames = [
(
if (system ? address && system.address ? tailnet) then
system.address.tailnet
else
common.tailnetAddr hostName
)
];
publicKey = system.ssh.publicKey;
}) systems;
users.users.${systemConfig.username}.openssh.authorizedKeys.keys = (
lib.mapAttrsToList (_hostName: system: system.ssh.publicKey) systems
);
}