Skip to content

Commit

Permalink
Generate host key and known_hosts for that key in the same step
Browse files Browse the repository at this point in the history
What happened with the test failure was that one step could not be
cached, but the other could! So now the known_hosts file diverged from
the hostkey (or the other way around).
  • Loading branch information
antifuchs committed Mar 17, 2024
1 parent 33712c2 commit 2d0c667
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions nixos/tests/flake-part.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
hostkey = pkgs.runCommand "hostkey" {buildInputs = [pkgs.openssh];} ''
mkdir $out
ssh-keygen -N "" -t ed25519 -f $out/hostkey
'';
knownHosts = pkgs.runCommand "known_hosts" {} ''
(echo -n 'alice-boot ' ; cat ${hostkey}/hostkey.pub) > $out
(echo -n 'alice-boot ' ; cat ${hostkey}/hostkey.pub) > $out/known_hosts
'';
clientKey = pkgs.runCommand "clientKey" {buildInputs = [pkgs.openssh];} ''
mkdir $out
Expand Down Expand Up @@ -145,9 +143,9 @@
ssh-keygen -l -f ${hostkey}/hostkey
echo "${hostkey} contents:" >&2
cat ${hostkey}/hostkey >&2
echo "${knownHosts} file contents:" >&2
cat ${knownHosts} >&2
echo | ssh -vvv -o UserKnownHostsFile=${knownHosts} -i /etc/sshKey shell@alice-boot
echo "${hostkey}/known_hosts file contents:" >&2
cat ${hostkey}/known_hosts >&2
echo | ssh -vvv -o UserKnownHostsFile=${hostkey}/known_hosts -i /etc/sshKey shell@alice-boot
'';
})
];
Expand Down

0 comments on commit 2d0c667

Please sign in to comment.