【问题标题】:"Kex error : did not find one of algos diffie-hellman-group1-sha1- in list" when connecting with sshlib与 sshlib 连接时,“Kex 错误:未在列表中找到算法 diffie-hellman-group1-sha1- 之一”
【发布时间】:2018-09-08 06:56:08
【问题描述】:

我正在 Windows 中实现 SFTP C++ 来传输一些文件。我已经通过using this 下载并附加了所有库(libssh 0.5.0)。

我从this author : Desphilboy 找到了一些代码。但它显示错误为:

错误:Kex 错误:在 list curve25519-sha256@libssh.org.ecdh-sha2-nistp256、ecdh-sha2-nistp384、ecdh-sha2-nistp521 中找不到算法 diffie-hellman-group1-sha1- 之一, diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 用于 kex 算法。无法连接 ssh 会话。1 错误:写入数据包:套接字错误(或连接关闭):没有错误。

我想使用这些系统用户名和密码连接到特定的 IP。对此有什么建议吗?

下面是我的主要课程

#include "ssh.h"

int main()
{
    pSFTPConnector  sshc = new  SFTPConnector(L".\\", L"147.13.5.123", 22, L"John", L"password");  // change the hostname , port , username, password to your sftp server, your credentials

    FILE *nullfile = fopen("null", "w");
    sshc->setLogFile(nullfile);
    sshc->setVerbosity(1);  // you can change the verbosity as appropriate for you

    int i = sshc->InitSession();
    if (i != E_OK) wprintf(L"%s", sshc->errstring.c_str());

    i = sshc->ConnectSession();
    if (i != E_OK) wprintf(L"%s", sshc->errstring.c_str());

    i = sshc->InitSFTP();
    if (i != E_OK) wprintf(L"%s", sshc->errstring.c_str());

    i = sshc->SFTPrename("renamed_myfile.txt", "myfile.txt");  //change these file names
    i = sshc->Makedir("sftpdir");
    i = sshc->testUploadFile("myfile2.txt", "1234567890testfile");


    i = sshc->SFTPreget("c:\\testdir\\reget_downloaded_CAR_HIRE_FINAL.jpg", "CAR_HIRE_FINAL.jpg", 64 * 1024);
    sshc->setBlockTransferDelay(1);

    i = sshc->GetSessionStatus();
    i = sshc->SFTPreput("c:\\testdir\\CentOS-6.5-x86_64-bin-DVD1.iso", "reput_CentOS-6.5-x86_64-bin-DVD1.iso", 64 * 1024);
    i = sshc->SFTPreput("c:\\testdir\\Reget_CentOS-6.5-x86_64-bin-DVD1.iso", "reput2_CentOS-6.5-x86_64-bin-DVD1.iso", 64 * 1024);

    if (i != E_OK) wprintf(L"%s", sshc->errstring.c_str());
    delete sshc;
    getchar();
    return 0;
}

头文件是 ssh.h 我按照this中的描述添加到我的项目中

【问题讨论】:

  • 我们需要准确完整的错误信息。
  • @MartinPrikryl:错误与“密钥交换算法”有关,但我想使用这些系统 IP 地址、用户名和密码连接到特定系统。如何解决这个问题?
  • 要使用 SSH 连接到系统,您需要交换密钥。所以,你需要解决那个“密钥交换算法”的问题。为了帮助您解决该问题,我们需要准确且完整的错误消息。不是您模糊和不完整的转录。
  • @MartinPrikryl:错误:Kex 错误:在列表 curve25519-sha256@libssh.org.ecdh-sha2-nistp256、ecdh-sha2- 中找不到算法 diffie-hellman-group1-sha1- 之一nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 用于 kex 算法。无法连接 ssh 会话。[1]错误:写入数据包:套接字错误(或连接关闭):没有错误。
  • 您使用的是什么版本的 libssh?最新版本没有这样的错误信息。

标签: c++ ssh sftp libssh


【解决方案1】:

libssh 0.5 已经 7 岁了。因此,它不支持许多最新服务器所需的现代算法。更不用说它可能存在许多安全问题。

使用最新版本的 libssh。

【讨论】:

  • 我想使用一个系统的 IP 地址、用户名和密码来连接和传输文件到另一个系统。我如何使用 SFTP 来做到这一点?有可能吗?
  • 我不明白你的评论。你知道怎么做的,对吧?使用 libssh。但请使用最新版本。
  • 我已经下载了最新版本的 libssh 并尝试使用基于 'stackoverflow.com/a/13666314/10330249' 的 cmake 和更多教程从源代码构建 ssh.lib,但没有任何工作正常。你能建议任何新的方法或教程来构建 ssh.lib
  • Stack Overflow 是问答网站,而不是论坛。如果您有新问题,请开始一个新问题。确保您更好地描述您的问题,而不是“没有正常工作”
猜你喜欢
  • 2012-03-14
  • 1970-01-01
  • 1970-01-01
  • 2018-03-08
  • 2016-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多