使用Chilkat库时出现“预期的KEX_DH_GEX_GROUP / KEXDH_REPLY”错误

时间:2013-09-11 09:46:24

标签: sftp chilkat

我正在评估Chilkat SFTP的新库。

但是,当连接到SFTP时,我收到如下错误:

ChilkatLog:
  Connect_SFtp:
    DllDate:2013年8月15日
    Chilkat版本:9.4.1.42
    UnlockPrefix:xxxxxxxx
    用户名:(隐藏)
    建筑:Little Endian; 32位
    语言:.NET 2.0
    详细记录:0
    SftpVersion:0
    主机名:xx.xxx.xxx.xxx
    港口:22
    ConnectTimeoutMs_1:50000
    调用ConnectSocket2
    启用IPV6连接NO心跳。
    这是一个IPV4数字地址...
    AddrInfoList:
      addrinfo中:
        ai_flags:4
        ai_family:2
        ai_socktype:1
        ai_protocol:0
        ai_addrlen:16
        ai_canonname :( NULL)
      --AddrInfo
    --AddrInfoList
    使用IPV4连接     ipAddress1:xx.xxx.xxx.xxx
    myIP_3:xx.x.xxx.xx
    myPort_3:50483
    连接成功(2)
    与SSH服务器建立TCP / IP连接
    打开TCP_NODELAY。
    clientIdentifier:SSH-2.0-PuTTY_Local:_May_11_2009_17:22:38
    发送客户端标识符...
    完成发送客户端标识符     阅读服务器版本...
    initialDataFromSshServer:SSH-2.0-0.0

serverVersion: SSH-2.0-0.0 
KeyExchangeAlgs:
  algorithm: diffie-hellman-group1-sha1
  algorithm: diffie-hellman-group-exchange-sha1
  algorithm: diffie-hellman-group14-sha1
--KeyExchangeAlgs
HostKeyAlgs:
  algorithm: ssh-dss
--HostKeyAlgs
EncCS:
  algorithm: aes256-cbc
  algorithm: aes192-cbc
  algorithm: aes128-cbc
  algorithm: twofish-cbc
  algorithm: blowfish-cbc
  algorithm: 3des-cbc
  algorithm: arcfour
--EncCS
EncSC:
  algorithm: aes256-cbc
  algorithm: aes192-cbc
  algorithm: aes128-cbc
  algorithm: twofish-cbc
  algorithm: blowfish-cbc
  algorithm: 3des-cbc
  algorithm: arcfour
--EncSC
MacCS:
  algorithm: hmac-sha1
  algorithm: hmac-sha1-96
  algorithm: hmac-md5
  algorithm: hmac-md5-96
--MacCS
MacSC:
  algorithm: hmac-sha1
  algorithm: hmac-sha1-96
  algorithm: hmac-md5
  algorithm: hmac-md5-96
--MacSC
CompCS:
  algorithm: zlib
  algorithm: none
--CompCS
CompSC:
  algorithm: zlib
  algorithm: none
--CompSC
Encryption: 256-bit AES CBC
Encryption: 256-bit AES CBC
MAC: HMAC-SHA1
MAC: HMAC-SHA1
Compression: zlib
Compression: zlib
Key Exchange: DH Group Exchange SHA1
Host Key Algorithm: DSS
numBits: 160
pbits: 2048
Using GEX Group.
Sending KEX_DH_GEX_REQUEST...
pbits: 2048
Unexpected message received.  Expected KEX_DH_GEX_GROUP/KEXDH_REPLY.
msgType: 1
Failed.

- Connect_SFtp --ChilkatLog


我主要使用4个功能连接到SFTP

sftp.UnlockComponent(ChilkatKey);  
sftp.Connect(hostname, port);  
sftp.AuthenticatePw(username, password);  
sftp.InitializeSftp();  

我错过了什么?谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

正确的顺序应该和你的一样:

但在那些人之后,你需要调用OpenDir和ReadDir(如果你需要获取远程文件夹上的文件计数)方法,比如;

string handler = sftp.OpenDir("remote_path");
SFtpDir compassDir = sftp.ReadDir(handler);

只需下载一个你不需要调用ReadDir的文件,但必须调用OpenDir。填充compassDir对象后,您可以通过;

获取文件计数
int fileAmount = compassDir.NumFilesAndDirs

或者您可以按名称下载文件;

sftp.DownloadFileByName("local_path","Remote_path_with_file_name");

对不起错字错误.....

相关问题