使用libcurl作为客户端与服务器进行密钥交换时会出现意外的算法

问题描述 投票:0回答:1

我们系统中ssh_config的密码配置为: 主机密钥算法 ecdsa-sha2-nistp256、ecdsa-sha2-nistp384、ecdsa-sha2-nistp521

当我使用ssh或sftp连接到服务器,并使用网络嗅探工具捕获数据包时,我们可以看到主机算法是正确的。

但是当我们使用libcurl上传一些文件到服务器时,网络嗅探工具会捕获到很多意想不到的算法: ecdsa-sha2-nistp256、ecdsa-sha2-nistp384、ecdsa-sha2-nistp521、[电子邮件受保护][电子邮件受保护][电子邮件受保护],ssh-ed25519,ssh-rsa,ssh-dss

代码部分如下:

CURL* curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void*)this);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, &FTSProgressFunction);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 60L);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 900); 
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 0);         
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);

curl_easy_setopt(curl, CURLOPT_USERNAME, username); 
curl_easy_setopt(curl, CURLOPT_PASSWORD, password); 
long anAuthType = 0;
anAuthType |= CURLSSH_AUTH_PASSWORD;  
curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, anAuthType);

curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, filesize);

/* enable uploading */ 
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);

/* specify target */ 
curl_easy_setopt(curl, CURLOPT_URL, remote_curl);

/* now specify which file to upload */ 
curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);

/* Now run off and do what you've been told! */ 
res = curl_easy_perform(curl);

我尝试为 libcurl 找到一些设置选项 api,但效果不佳。 Libcur 版本: libcurl -v
卷曲 7.82.0 (powerpc-fsl-linux-gnu) libcurl/7.82.0 OpenSSL/3.0.12 zlib/1.2.11 libssh2/1.10.0 发布日期:2022-03-05

linux sftp libcurl openssh
1个回答
0
投票

我发现一些信息说libcurl依赖libssh,而libssh实际上没有使用Openssh的ssh_config,我们应该为libssh使用ssh_options_set和ssh_options_parse_config。这是正确的吗?

© www.soinside.com 2019 - 2024. All rights reserved.