openssh: test that startWhenNeeded works

This commit is contained in:
Graham Christensen 2016-12-29 09:49:43 -05:00
parent 8ed4c8b73b
commit bf659128a0
No known key found for this signature in database
GPG Key ID: 06121D366FE9435C

View File

@ -35,6 +35,18 @@ in {
];
};
server_lazy =
{ config, pkgs, ... }:
{
services.openssh = { enable = true; startWhenNeeded = true; };
security.pam.services.sshd.limits =
[ { domain = "*"; item = "memlock"; type = "-"; value = 1024; } ];
users.extraUsers.root.openssh.authorizedKeys.keys = [
snakeOilPublicKey
];
};
client =
{ config, pkgs, ... }: { };
@ -50,6 +62,8 @@ in {
subtest "manual-authkey", sub {
$server->succeed("mkdir -m 700 /root/.ssh");
$server->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
$server_lazy->succeed("mkdir -m 700 /root/.ssh");
$server_lazy->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
$client->succeed("mkdir -m 700 /root/.ssh");
$client->copyFileFromHost("key", "/root/.ssh/id_ed25519");
@ -58,6 +72,10 @@ in {
$client->waitForUnit("network.target");
$client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'echo hello world' >&2");
$client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'ulimit -l' | grep 1024");
$client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server_lazy 'echo hello world' >&2");
$client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server_lazy 'ulimit -l' | grep 1024");
};
subtest "configured-authkey", sub {
@ -66,6 +84,11 @@ in {
$client->succeed("ssh -o UserKnownHostsFile=/dev/null" .
" -o StrictHostKeyChecking=no -i privkey.snakeoil" .
" server true");
$client->succeed("ssh -o UserKnownHostsFile=/dev/null" .
" -o StrictHostKeyChecking=no -i privkey.snakeoil" .
" server_lazy true");
};
'';
})