43

JSch (0.1.44-1) を使用して ssh 経由でリモート sftp サーバーに接続しようとしていますがsession.connect();、この例外が発生しています:

com.jcraft.jsch.JSchException: Algorithm negotiation fail at 
com.jcraft.jsch.Session.receive_kexinit(Session.java:529) at 
com.jcraft.jsch.Session.connect(Session.java:291) at com.jcraft.jsch.Session.connect(Session.java:154)
... 

JSch からのログ:

INFO: Connecting to xx.xx.xx.xxport 22 
INFO: Connection established 
INFO: Remote version string: SSH-2.0-WeOnlyDo 2.0.6 
INFO: Local version string: SSH-2.0-JSCH-0.1.44 
INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
INFO: aes256-ctr is not available. 
INFO: aes192-ctr is not available.
INFO: aes256-cbc is not available. 
INFO: aes192-cbc is not available.
INFO: arcfour256 is not available. 
INFO: SSH_MSG_KEXINIT sent
INFO: SSH_MSG_KEXINIT received 
INFO: Disconnecting from xx.xx.xx.xx port 22 

Linux sftp コマンドを使用してリモート サーバーにログインできます。インターネットで何らかの手がかりを見つけようとしましたが、失敗しました。

Linux sftp コマンドからのデバッグ出力:

OpenSSH_5.5p1-DAM_1.2, OpenSSL 0.9.8r 8 Feb 201

debug1: Reading configuration data /etc/DAM/ssh/ssh_config
debug1: Applying options for *
debug1: Applying options for *.*
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /**/spv_id_rsa.key type -1
debug1: identity file /**/spv_id_rsa.key-cert type -1
debug1: Remote protocol version 2.0, remote software version WeOnlyDo 2.0.6
debug1: no match: WeOnlyDo 2.0.6
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1-DAM_1.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes256-cbc hmac-md5 none
debug1: kex: client->server aes256-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'xx.xx.xx.xx' is known and matches the RSA host key.
debug1: Found key in ~/.ssh/known_hosts:8
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /**/spv_id_rsa.key
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending subsystem: sftp
Connected to xx.xx.xx.xx.
sftp>
4

11 に答える 11

31

SSH クライアントとサーバーが共通の実装を試みて合意する場所がいくつかあります。私が知っている 2 つは、暗号化と圧縮です。サーバーとクライアントは利用可能なオプションのリストを作成し、両方のリストで利用可能な最適なオプションが選択されます。

リストに受け入れ可能なオプションがない場合、取得したエラーで失敗します。ここのデバッグ出力から推測していますが、暗号化のサーバー オプションは「aes256-cbc hmac-md5 none」のみのようです。

JSch は hmac-md5 を実行せず、aes256-cbc は Java ポリシー ファイルのために無効になっています。あなたが試すことができる2つのことは...

  1. サーバーで利用可能な暗号化ライブラリを増やすには、クライアントに無制限のポリシー ファイルをインストールし、サイトから aes256-cbc を有効にします (無効になっているというメッセージが消えていることを確認してください。これらのポリシー ファイルは、間違った JVM に簡単にインストールできることで有名です)。 :

    JDK 1.6 の場合: http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html

    JDK 1.7 の場合: http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html

    JDK 1.8 の場合: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

  2. または、暗号化を無効にしてみてください。

サーバーにアクセスできる場合は最初の方法が理想的ですが (aes128-cbc は十分な暗号化機能を備えていると信じてください)、2 番目の方法は理論をすばやくテストするのに十分簡単です。

于 2011-06-07T12:41:02.720 に答える
24

最後に、サーバーに変更を加えることなく機能するソリューション:

  1. Yvan の提案に従って、最新の jsch.jar をダウンロードします 。http://sourceforge.net/projects/jsch/files/jsch.jar/

  2. ダウンロードしたファイルを「...\JetBrains\PhpStorm 8.0.1\lib」に配置し、既存の jsch ファイルを削除します (PHPStorm 8 の場合は jsch-0.1.50.jar です)。

  3. PHPStorm を再起動すると、動作するはずです

Webstorm に同じソリューションを使用する

于 2015-07-16T16:45:30.337 に答える
11

RECEIVING サーバー (接続先のサーバー) にアルゴリズムを追加するための完全な手順。これはLinuxサーバーであると想定しています。

sudo /etc/ssh/sshd_config

これをファイルに追加します(最後にある場合があります):

KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

次に、SSH サーバーを再起動します。

sudo service sshd restart
于 2016-12-20T22:23:49.890 に答える
9

FWIW、JSch 0.1.50 で同じエラー メッセージが表示されました。0.1.52 にアップグレードすると問題が解決しました。

于 2015-05-10T11:03:25.783 に答える
1

KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha‌ 1をサーバーの sshd_config に追加します。

これは機能しましたが、必ず sshd を再起動してください: sudo service sshd restart

于 2016-08-20T01:19:14.773 に答える