2

I'm implementing SFTP C++ in Windows to transfer some files. I have downloaded and attached all the libraries for this (libssh 0.5.0) by using this .

I found some code from this author : Desphilboy. But it showing errors as:

Error: Kex error : did not find one of algos diffie-hellman-group1-sha1- in list curve25519-sha256@libssh.org.ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 for kex algos. Could not connect the ssh session.1 Error : Writing packet: error on socket(or connection closed): No error.

I want to connect to the particular IP by using those system username and password. Any suggestion for this ?

Below is my main class

#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;
}

The header file is ssh.h I added into my project as described in this

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • We need exact and full error message. – Martin Prikryl Sep 08 '18 at 07:23
  • @MartinPrikryl : The error is about "Key exchange algorithm", but i want to connect to the particular system by using those system IP address, username and password. how this issue can be resolved? –  Sep 08 '18 at 07:43
  • To connect to a system with SSH, you need to exchange keys. So, you need to fix that *"key exchange algorithm"* problem. To help you fixing that problem, we need an exact and full error message. Not your vague and incomplete transcription. – Martin Prikryl Sep 08 '18 at 11:58
  • @MartinPrikryl : Error: Kex error : did not find one of algos diffie-hellman-group1-sha1- in list curve25519-sha256@libssh.org.ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 for kex algos. Could not connect the ssh session.[1] Error : Writing packet: error on socket(or connection closed): No error. –  Sep 10 '18 at 05:07
  • What version of libssh are you using? There's no such error message in the latest version. – Martin Prikryl Sep 10 '18 at 05:16
  • @MartinPrikryl: I'm using 'libssh-0.5.0' .I downloaded the 'libssh-0.8.2', but those not contains the ssh.lib hence i go through some tutorial, but its difficult to build ssh.lib by using Cmake, do u have any suggestions ? –  Sep 10 '18 at 05:41
  • @MartinPrikryl : I would like to connect and transfer files from one system to other by using its IP address, Username and password. How Can i do it by using SFTP? –  Sep 10 '18 at 05:46

1 Answers1

0

libssh 0.5 is 7 years old. Hence it does not support modern algorithms that many up-to-date servers need. Not to mention that it probably has numerous security issues.

Use the latest version of libssh.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • I would like to connect and transfer files from one system to other by using its IP address, Username and password. How Can i do it by using SFTP? Is it possible ? –  Sep 10 '18 at 06:22
  • I do not understand your comment. You know how do it, right? Use libssh. But use the latest version. – Martin Prikryl Sep 10 '18 at 06:27
  • I have downloaded the latest version of libssh and tried to build ssh.lib from the source by using cmake based on 'https://stackoverflow.com/a/13666314/10330249' and some more tutorial ,but nothing work properly. Can u suggest any new methods or tutorial to build ssh.lib –  Sep 10 '18 at 07:49
  • Stack Overflow is Q&A site, not a discussion forum. If you have a new problem, please start a new question. Make sure you **describe your problem a way better** than by *"nothing work properly"*. – Martin Prikryl Sep 10 '18 at 07:51