From 41da111000ecd7237338d8e2be52d8e431616a44 Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Sat, 21 Nov 2026 18:10:13 +0100 Subject: [PATCH 1/2] ajouts ssh --- hosts/physiques/cephiroth/info.nix | 4 ++++ hosts/physiques/thot/info.nix | 2 ++ hosts/vm/apprentix/info.nix | 2 ++ hosts/vm/collabora/info.nix | 2 ++ hosts/vm/coturn/info.nix | 2 ++ hosts/vm/jitsi/info.nix | 2 ++ hosts/vm/livre/info.nix | 2 ++ hosts/vm/mediakiwi/info.nix | 2 ++ hosts/vm/neo/info.nix | 2 ++ hosts/vm/nextcloud/info.nix | 2 ++ hosts/vm/periodique/info.nix | 2 ++ hosts/vm/reverseproxy/info.nix | 2 ++ hosts/vm/two/info.nix | 2 ++ hosts/vm/vaultwarden/info.nix | 2 ++ modules/info/meta.nix | 5 +++-- 15 files changed, 33 insertions(+), 2 deletions(-) diff --git a/hosts/physiques/cephiroth/info.nix b/hosts/physiques/cephiroth/info.nix index e2f7b28..658f166 100644 --- a/hosts/physiques/cephiroth/info.nix +++ b/hosts/physiques/cephiroth/info.nix @@ -16,6 +16,10 @@ }; }; + resticClient.enable = false; + + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOsBGkhiu6l3jeo15cQHMu3dPyL025zXPV2ZH02EDYEt root@cephiroth"; + ilo = { id = 53; switch.salameche = 20; diff --git a/hosts/physiques/thot/info.nix b/hosts/physiques/thot/info.nix index e46cfc5..d4d7d86 100644 --- a/hosts/physiques/thot/info.nix +++ b/hosts/physiques/thot/info.nix @@ -13,5 +13,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFKNg1b8ft1L55+joXQ/7Dt2QTOdkea8opTEnq4xrhPU root@thot"; + resticClient.enable = false; } diff --git a/hosts/vm/apprentix/info.nix b/hosts/vm/apprentix/info.nix index f569b99..c5ce2fb 100644 --- a/hosts/vm/apprentix/info.nix +++ b/hosts/vm/apprentix/info.nix @@ -13,5 +13,7 @@ homeNounou.enable = false; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDCJV6jqQWEYuwi+OJ9r/4TbBN/cK9NvYWNiJhpFzcc7 root@apprentix"; + users.root.passwordFile = ../../../secrets/apprentix/root.age; } diff --git a/hosts/vm/collabora/info.nix b/hosts/vm/collabora/info.nix index ebe835a..a95b90d 100644 --- a/hosts/vm/collabora/info.nix +++ b/hosts/vm/collabora/info.nix @@ -21,5 +21,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFa2D9fREtO2r2oIx6q9JAKFUHtxGbgEPMjkx09DQSU8 root@collabora"; + resticClient.enable = false; } diff --git a/hosts/vm/coturn/info.nix b/hosts/vm/coturn/info.nix index 7d99a69..971c283 100644 --- a/hosts/vm/coturn/info.nix +++ b/hosts/vm/coturn/info.nix @@ -19,6 +19,8 @@ resticClient.when = "06:07"; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGoR66An5huQucZlueQCcB/vwd085wrS2mUIz39e8QLt root@coturn"; + services = { acme.enable = true; }; diff --git a/hosts/vm/jitsi/info.nix b/hosts/vm/jitsi/info.nix index 3b2b3f9..396f68b 100644 --- a/hosts/vm/jitsi/info.nix +++ b/hosts/vm/jitsi/info.nix @@ -19,6 +19,8 @@ resticClient.when = "02:34"; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB6jVMIZ5y2oXX9HOkw7r5UUjw95MlFaFuu7FnEC0Q8z root@jitsi"; + services = { acme.enable = true; }; diff --git a/hosts/vm/livre/info.nix b/hosts/vm/livre/info.nix index 8df46c7..0418b53 100644 --- a/hosts/vm/livre/info.nix +++ b/hosts/vm/livre/info.nix @@ -25,5 +25,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEVfKNokHG6ig32hhQxTep+fKFmKahlDClPrX/dP4/gb root@livre"; + resticClient.when = "03:45"; } diff --git a/hosts/vm/mediakiwi/info.nix b/hosts/vm/mediakiwi/info.nix index 9c83a63..d31ecfa 100644 --- a/hosts/vm/mediakiwi/info.nix +++ b/hosts/vm/mediakiwi/info.nix @@ -38,5 +38,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFfcKtim7Aj+strHdg847D7KCCdoOAuasxx/2yi2TY1n root@mediakiwi"; + resticClient.when = "06:47"; } diff --git a/hosts/vm/neo/info.nix b/hosts/vm/neo/info.nix index 07716d6..ff5d7b3 100644 --- a/hosts/vm/neo/info.nix +++ b/hosts/vm/neo/info.nix @@ -18,6 +18,8 @@ resticClient.when = "04:56"; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMGfSvxqC2PJYRrxJaivVDujwlwCZ6AwH8hOSA9ktZ1V root@neo"; + services = { acme.enable = true; }; diff --git a/hosts/vm/nextcloud/info.nix b/hosts/vm/nextcloud/info.nix index d6f900b..2a6033f 100644 --- a/hosts/vm/nextcloud/info.nix +++ b/hosts/vm/nextcloud/info.nix @@ -25,5 +25,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMgSP9UmuJw8Bi2ML07WHsWvxN8akkc9XZxXyOgdjXkq root@nextcloud"; + resticClient.enable = false; } diff --git a/hosts/vm/periodique/info.nix b/hosts/vm/periodique/info.nix index fa2da9b..3870bf1 100644 --- a/hosts/vm/periodique/info.nix +++ b/hosts/vm/periodique/info.nix @@ -23,5 +23,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTdfSIL3AWIv0mjRDam6E/qsjoqwJ8QSm1Cb0xqs1s1 root@periodique"; + resticClient.when = "02:56"; } diff --git a/hosts/vm/reverseproxy/info.nix b/hosts/vm/reverseproxy/info.nix index da7699d..b013eb8 100644 --- a/hosts/vm/reverseproxy/info.nix +++ b/hosts/vm/reverseproxy/info.nix @@ -20,5 +20,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOx/lUQE6naP3EBy81sr93X8ktZmivU09ACx6T43Odhb root@reverseproxy"; + resticClient.when = "03:42"; } diff --git a/hosts/vm/two/info.nix b/hosts/vm/two/info.nix index c345d86..2cb06e2 100644 --- a/hosts/vm/two/info.nix +++ b/hosts/vm/two/info.nix @@ -12,5 +12,7 @@ }; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPpaGf8A+XWXBdNrs69RiC0qPbjPHdtkl31OjxrktmF6 root@two"; + resticClient.when = "07:29"; } diff --git a/hosts/vm/vaultwarden/info.nix b/hosts/vm/vaultwarden/info.nix index 6efcbf0..23c447a 100644 --- a/hosts/vm/vaultwarden/info.nix +++ b/hosts/vm/vaultwarden/info.nix @@ -21,5 +21,7 @@ nginx.enable = true; }; + publicSsh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICn6vfDlsZVU6TEWg9vTgq9+Fp3irHjytBTky7A4ErRM root@vaultwarden"; + resticClient.when = "04:44"; } diff --git a/modules/info/meta.nix b/modules/info/meta.nix index ef5cab8..ad18efb 100644 --- a/modules/info/meta.nix +++ b/modules/info/meta.nix @@ -35,8 +35,9 @@ in default = false; }; - public-ssh = mkOption { - type = types.str; + publicSsh = mkOption { + type = types.nullOr types.str; + default = null; description = "Clé ssh publique de la machine."; }; }; From ab370ae9fb4fe17511b14f12e2c4411fb07d46f8 Mon Sep 17 00:00:00 2001 From: Pyjacpp Date: Sat, 21 Nov 2026 18:56:55 +0100 Subject: [PATCH 2/2] feat: known hosts via les infos.nix --- hosts/physiques/cephiroth/info.nix | 1 + modules/crans/ssh.nix | 47 ++++++++++++++++++++++++++++-- modules/info/default.nix | 2 +- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/hosts/physiques/cephiroth/info.nix b/hosts/physiques/cephiroth/info.nix index 658f166..b0cc869 100644 --- a/hosts/physiques/cephiroth/info.nix +++ b/hosts/physiques/cephiroth/info.nix @@ -3,6 +3,7 @@ description = "Serveur de stockage ceph"; id = 3; + enable = true; # Sous Nix mais dans une autre branche isDebian = true; diff --git a/modules/crans/ssh.nix b/modules/crans/ssh.nix index 3bea073..57520fd 100644 --- a/modules/crans/ssh.nix +++ b/modules/crans/ssh.nix @@ -1,5 +1,19 @@ -{ ... }: - +{ + infra, + lib, + hosts, + ... +}: +let + inherit (lib) + attrNames + concatMap + optional + mapAttrs' + mkIf + nameValuePair + ; +in { services.openssh = { enable = true; @@ -7,5 +21,34 @@ settings = { PermitRootLogin = "yes"; }; + + # knownHosts : + # { + # "host" = { + # hostNames = ["host.adm.crans.org" 172.16.10.2 …] + # publicKey = "ssh-ed25519…" + # } + # } + knownHosts = mapAttrs' ( + n: conf: + nameValuePair n ( + mkIf (conf.publicSsh != null) { + publicKey = conf.publicSsh; + + hostNames = [ + "${n}.adm.crans.org" + ] + ++ concatMap ( + vlan: + let + netv = conf.networking.${vlan}; + in + optional (netv.enable && (netv.ipv4.address or null) != null) netv.ipv4.address + ++ optional (netv.enable && (netv.ipv6.address or null) != null) netv.ipv6.address + ) (attrNames infra.vlans); + } + ) + ) hosts; + }; } diff --git a/modules/info/default.nix b/modules/info/default.nix index 8fd8502..27bdfa0 100644 --- a/modules/info/default.nix +++ b/modules/info/default.nix @@ -27,7 +27,7 @@ in example = true; description = "Activer la configuration Crans par défaut"; # On n’utilise pas mkEnableOption pour forcer la définition de enable à true - # ou false (et limiter les oublis) + # ou false (et limiter les oublis). }; config = mkIf config.enable { homeNounou.enable = mkDefault true;