Skip to content

Commit ffcbf8c

Browse files
tiemergify[bot]
authored andcommitted
check that host key is copied in tests
1 parent a8d94ff commit ffcbf8c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/from-nixos.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
start_all()
2323
installer.succeed("mkdir -p /tmp/extra-files/var/lib/secrets")
2424
installer.succeed("echo value > /tmp/extra-files/var/lib/secrets/key")
25+
ssh_key_path = "/etc/ssh/ssh_host_ed25519_key.pub"
26+
ssh_key_output = installer.wait_until_succeeds(f"""
27+
ssh -i /root/.ssh/install_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
28+
root@installed cat {ssh_key_path}
29+
""")
2530
installer.succeed("""
2631
nixos-anywhere \
2732
-i /root/.ssh/install_key \
@@ -43,5 +48,7 @@
4348
assert "nixos-anywhere" == hostname, f"'nixos-anywhere' != '{hostname}'"
4449
content = new_machine.succeed("cat /var/lib/secrets/key").strip()
4550
assert "value" == content, f"secret does not have expected value: {content}"
51+
ssh_key_content = new_machine.succeed(f"cat {ssh_key_path}").strip()
52+
assert ssh_key_content in ssh_key_output, "SSH host identity changed"
4653
'';
4754
}

0 commit comments

Comments
 (0)