runtests: allow configuring SSH host/client key algorithm

via env `CURL_TEST_SSH_KEYALGO`, `rsa` (default), `ecdsa`, `ed25519`.

To ease debugging and testing and to make these code paths more
universal.

Closes #21223
This commit is contained in:
Viktor Szakats 2026-04-02 01:05:54 +02:00
parent 2e5d219205
commit acda4eae5e
No known key found for this signature in database
7 changed files with 44 additions and 13 deletions

View file

@ -1784,6 +1784,17 @@ sub runrtspserver {
return (0, $rtsppid, $pid2, $port);
}
#***************************************************************************
# Return key algorithm string
#
sub sshkeyalgostr {
my ($algo) = @_;
my %algomap = (
ecdsa => 'ecdsa-sha2-nistp256',
);
return exists $algomap{$algo} ? $algomap{$algo} : 'ssh-' . $algo;
}
#######################################################################
# Start the ssh (scp/sftp) server
#
@ -1831,6 +1842,9 @@ sub runsshserver {
$flags .= "--id $idnum " if($idnum > 1);
$flags .= "--ipv$ipvnum --addr \"$ip\" ";
$flags .= "--user \"$USER\"";
if(defined $feature{"sshkeyalgo"}) {
$flags .= ' --keyalgo ' . $feature{"sshkeyalgo"};
}
my @tports;
my $port = getfreeport($ipvnum);
@ -3199,6 +3213,8 @@ sub subvariables {
$$thing =~ s/${prefix}SSHSRVMD5/$SSHSRVMD5/g;
$$thing =~ s/${prefix}SSHSRVSHA256/$SSHSRVSHA256/g;
my $keyalgostr = sshkeyalgostr(defined $feature{"sshkeyalgo"} ? $feature{"sshkeyalgo"} : "");
$$thing =~ s/${prefix}SSHKEYALGO/$keyalgostr/g;
# The purpose of FTPTIME2 is to provide times that can be
# used for time-out tests and that would work on most hosts as these