Do SSH keys earlier (#37)

This commit is contained in:
Patrick Stevens
2025-03-07 21:41:19 +00:00
committed by GitHub
parent 656b93b248
commit fcd5cb82a8

View File

@@ -1,4 +1,4 @@
namespace PulumiWebServer namespace PulumiWebServer
open System.Net.Http open System.Net.Http
open Nager.PublicSuffix open Nager.PublicSuffix
@@ -115,6 +115,15 @@ module Program =
(BashString.make "/tmp/networking.nix") (BashString.make "/tmp/networking.nix")
|> fun c -> c.Stdout |> fun c -> c.Stdout
// TODO: do this properly via Command
keys
|> Array.map (fun k -> k.PublicKeyContents)
|> Array.collect (fun s -> s.Split "\n")
|> JsonConvert.SerializeObject
|> fun s -> File.WriteAllText ("/tmp/ssh-keys.json", s)
Log.Info "Stored SSH keys at /tmp/ssh-keys.json"
let pullHardware = let pullHardware =
Command.pullFile Command.pullFile
config.PrivateKey config.PrivateKey
@@ -130,15 +139,6 @@ module Program =
let! _ = pullHardware let! _ = pullHardware
Log.Info "Hardware configuration at /tmp/hardware.nix" Log.Info "Hardware configuration at /tmp/hardware.nix"
// TODO: do this properly via Command
keys
|> Array.map (fun k -> k.PublicKeyContents)
|> Array.collect (fun s -> s.Split "\n")
|> JsonConvert.SerializeObject
|> fun s -> File.WriteAllText ("/tmp/ssh-keys.json", s)
Log.Info "Stored SSH keys at /tmp/ssh-keys.json"
// The nixos rebuild has blatted the known public key. // The nixos rebuild has blatted the known public key.
let! _ = (Local.forgetKey (address.Get ())).Stdout let! _ = (Local.forgetKey (address.Get ())).Stdout
let! _ = (Local.forgetKey (string<DomainName> config.Domain)).Stderr let! _ = (Local.forgetKey (string<DomainName> config.Domain)).Stderr