2

SFTP に接続しようとしていますが、関数 sftp.Connect(hostname, port) で Chilkat から次のエラーが発生しています...

DllDate: 2010 年 12 月 22 日 UnlockPrefix: * ユーザー名: コンポーネント: .NET 2.0 SftpVersion: 0 ホスト名: . . ポート: 22 ConnectTimeoutMs: 50000

calling ConnectSocket2 これは IPV4 数値アドレスです... IPV4 を使用して接続します。IP アドレス: . .* socketHandle: 0x804 ai_addrlen: 16 ai_addr: 0200 0016 4B7F 64D8 0000 0000 0000 0000

myIP_3: **.***.***.***
myPort_3: *****
connect successful.
Established TCP/IP connection with SSH server
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
HostKeyAlgs:
  algorithm: ssh-dss
EncCS:
  algorithm: aes256-cbc
  algorithm: aes192-cbc
  algorithm: aes128-cbc
  algorithm: twofish-cbc
  algorithm: blowfish-cbc
  algorithm: 3des-cbc
  algorithm: arcfour
EncSC:
  algorithm: aes256-cbc
  algorithm: aes192-cbc
  algorithm: aes128-cbc
  algorithm: twofish-cbc
  algorithm: blowfish-cbc
  algorithm: 3des-cbc
  algorithm: arcfour
MacCS:
  algorithm: hmac-sha1
  algorithm: hmac-sha1-96
  algorithm: hmac-md5
  algorithm: hmac-md5-96
MacSC:
  algorithm: hmac-sha1
  algorithm: hmac-sha1-96
  algorithm: hmac-md5
  algorithm: hmac-md5-96
CompCS:
  algorithm: zlib
  algorithm: none
CompSC:
  algorithm: zlib
  algorithm: none
Encryption: 256-bit AES
Encryption: 256-bit AES
MAC: HMAC-SHA1
MAC: HMAC-SHA1
Compression: none
Compression: none
Key Exchange: DH Group Exchange SHA1
Host Key Algorithm: DSS
numBits: 160
pbits: 2048

GEXグループを利用。KEX_DH_GEX_REQUEST を送信しています... pbits: 2048

予期しないメッセージが受信されました。KEX_DH_GEX_GROUP が必要です。msgType: 1

失敗した。

私は主に4つの機能を使用してSFTPに接続しています

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

私は何が欠けていますか? ご協力いただきありがとうございます。

4

1 に答える 1

0

正しい順序は次のようになります。

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

しかし、それらの人たちの後、次のような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");

誤字脱字すみません。

于 2013-10-18T15:53:45.777 に答える