feat(neogaia): restore the SSH host keys from sops (task 0011)
The host's SSH identity was generated by the daemon, so reimaging the laptop would invalidate it and break `known_hosts` for every client that had ever connected. Add `secrets/neogaia.yaml`, the first per-host secrets file, encrypted to the admin identity and `neogaia` alone so a compromised machine cannot decrypt another's material. It holds both host private keys; the public halves are committed in plaintext. Clear `services.openssh.hostKeys` to stop generation and point `HostKey` at the decrypted paths. These are ordinary secrets rather than the pre-user ones the password uses, exercising the second decryption path.
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
{ inputs, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
# neogaia — Dell XPS 13 9380 laptop.
|
||||
# Disk layout is in ./disk.nix; `fileSystems` are derived from it, none declared here.
|
||||
let
|
||||
# Read by the daemon at startup, so a re-key has to restart it to take effect.
|
||||
sshHostKey = {
|
||||
sopsFile = ../../secrets/neogaia.yaml;
|
||||
mode = "0400";
|
||||
restartUnits = [ "sshd.service" ];
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
inputs.nixos-hardware.nixosModules.dell-xps-13-9380
|
||||
@@ -29,6 +42,23 @@
|
||||
# So setup can be driven over the network.
|
||||
services.openssh.enable = true;
|
||||
|
||||
# This host's SSH identity is restored from secrets.
|
||||
# Reimaging the machine therefore keeps its fingerprint, and every client's
|
||||
# `known_hosts` entry stays valid.
|
||||
# The matching public halves are committed in plaintext, since publishing
|
||||
# them is their purpose.
|
||||
sops.secrets = {
|
||||
ssh-host-ed25519-key = sshHostKey;
|
||||
ssh-host-rsa-key = sshHostKey;
|
||||
};
|
||||
|
||||
# An empty list is what stops the daemon generating keys of its own.
|
||||
services.openssh.hostKeys = [ ];
|
||||
services.openssh.extraConfig = ''
|
||||
HostKey ${config.sops.secrets.ssh-host-ed25519-key.path}
|
||||
HostKey ${config.sops.secrets.ssh-host-rsa-key.path}
|
||||
'';
|
||||
|
||||
# fish as the login shell.
|
||||
modules.fish.enable = true;
|
||||
modules.fish.defaultShell = true;
|
||||
|
||||
Reference in New Issue
Block a user