Skip to content

Commit f732f54

Browse files
committed
ssh: add kexAlgorithms to matchBlocks
This commit adds the option to add kexAlgorithms as an matchBlock option with updated test case.
1 parent e825853 commit f732f54

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

modules/programs/ssh.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,18 @@ let
404404
example = "10m";
405405
description = "Whether control socket should remain open in the background.";
406406
};
407+
408+
kexAlgorithms = mkOption {
409+
type = types.nullOr (types.listOf types.str);
410+
default = null;
411+
example = [
412+
413+
"diffie-hellman-group-exchange-sha256"
414+
];
415+
description = ''
416+
Specifies the available KEX (Key Exchange) algorithms.
417+
'';
418+
};
407419
};
408420

409421
# config.host = mkDefault dagName;
@@ -451,6 +463,9 @@ let
451463
++ map (f: " LocalForward" + addressPort f.bind + addressPort f.host) cf.localForwards
452464
++ map (f: " RemoteForward" + addressPort f.bind + addressPort f.host) cf.remoteForwards
453465
++ map (f: " DynamicForward" + addressPort f) cf.dynamicForwards
466+
++ optional (
467+
cf.kexAlgorithms != null
468+
) " KexAlgorithms ${builtins.concatStringsSep "," cf.kexAlgorithms}"
454469
++ mapAttrsToList (n: v: " ${n} ${v}") cf.extraOptions
455470
);
456471

tests/modules/programs/ssh/match-blocks-attrs-expected.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Host xyz
1313
RemoteForward [localhost]:8081 [10.0.0.2]:80
1414
RemoteForward /run/user/1000/gnupg/S.gpg-agent.extra /run/user/1000/gnupg/S.gpg-agent
1515
DynamicForward [localhost]:2839
16+
KexAlgorithms sntrup761x25519-sha512,[email protected],mlkem768x25519-sha256
1617
Host ordered
1718
Port 1
1819

tests/modules/programs/ssh/match-blocks-attrs.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
host.address = "/run/user/1000/gnupg/S.gpg-agent";
3535
}
3636
];
37+
kexAlgorithms = [
38+
"sntrup761x25519-sha512"
39+
40+
"mlkem768x25519-sha256"
41+
];
3742
dynamicForwards = [ { port = 2839; } ];
3843
setEnv = {
3944
FOO = "foo12";

0 commit comments

Comments
 (0)