Skip to content

Commit 3bf9d2a

Browse files
drakkanFiloSottile
authored andcommitted
ssh/test: skip KEX test if unsupported by system SSH client
Skip the key exchange test when using the system's ssh CLI if the required KEX algorithm (e.g., mlkem768x25519-sha256) is not supported. This is determined by running ssh -Q kex and checking for the presence of the target algorithm. Prevents false test failures in CI environments with older or limited SSH implementations. Cq-Include-Trybots: luci.golang.try:x_crypto-gotip-darwin-amd64-longtest,x_crypto-gotip-linux-amd64-longtest,x_crypto-gotip-windows-amd64-longtest Change-Id: I3fac703ec70559e18b30d5fff88274335a7c3952 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/679195 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 9bab967 commit 3bf9d2a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ssh/test/sshcli_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ func TestSSHCLIKeyExchanges(t *testing.T) {
119119
keyExchanges := append(ssh.SupportedAlgorithms().KeyExchanges, ssh.InsecureAlgorithms().KeyExchanges...)
120120
for _, kex := range keyExchanges {
121121
t.Run(kex, func(t *testing.T) {
122+
cmd := testenv.Command(t, sshCLI, "-Q", "kex")
123+
out, err := cmd.CombinedOutput()
124+
if err != nil {
125+
t.Fatalf("%s failed to check if the KEX is supported, error: %v, command output %q", kex, err, string(out))
126+
}
127+
if !bytes.Contains(out, []byte(kex)) {
128+
t.Skipf("KEX %q is not supported in the installed ssh CLI", kex)
129+
}
122130
config := &ssh.ServerConfig{
123131
Config: ssh.Config{
124132
KeyExchanges: []string{kex},
@@ -144,9 +152,9 @@ func TestSSHCLIKeyExchanges(t *testing.T) {
144152
t.Fatalf("unable to get server port: %v", err)
145153
}
146154

147-
cmd := testenv.Command(t, sshCLI, "-vvv", "-i", keyPrivPath, "-o", "StrictHostKeyChecking=no",
155+
cmd = testenv.Command(t, sshCLI, "-vvv", "-i", keyPrivPath, "-o", "StrictHostKeyChecking=no",
148156
"-o", fmt.Sprintf("KexAlgorithms=%s", kex), "-p", port, "[email protected]", "true")
149-
out, err := cmd.CombinedOutput()
157+
out, err = cmd.CombinedOutput()
150158
if err != nil {
151159
t.Fatalf("%s failed, error: %v, command output %q", kex, err, string(out))
152160
}

0 commit comments

Comments
 (0)