1 import ./make-test-python.nix ({ pkgs, lib, ... }:
2 let inherit (import ./ssh-keys.nix pkgs)
3 snakeOilPrivateKey snakeOilPublicKey;
4 ssh-config = builtins.toFile "ssh.conf" ''
5 UserKnownHostsFile=/dev/null
6 StrictHostKeyChecking=no
9 { name = "nix-ssh-serve";
10 meta.maintainers = [ lib.maintainers.shlevy ];
12 { server.nix.sshServe =
14 keys = [ snakeOilPublicKey ];
17 server.nix.package = pkgs.nix;
18 client.nix.package = pkgs.nix;
23 client.succeed("mkdir -m 700 /root/.ssh")
25 "cat ${ssh-config} > /root/.ssh/config"
28 "cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa"
30 client.succeed("chmod 600 /root/.ssh/id_ecdsa")
32 client.succeed("nix-store --add /etc/machine-id > mach-id-path")
34 server.wait_for_unit("sshd")
36 client.fail("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
37 # Currently due to shared store this is a noop :(
38 client.succeed("nix copy --to ssh-ng://nix-ssh@server $(cat mach-id-path)")
40 "nix-store --realise $(cat mach-id-path) --store /root/other-store --substituters ssh-ng://nix-ssh@server"
42 client.succeed("diff /root/other-store$(cat mach-id-path) /etc/machine-id")