2017-04-05 31 views
1

と0.1.49以降では以前JSCH 0.1.48は罰金働いていたが、私は変更すると、最近、それは例外を作業して投げJSCH 0.1.48で認証失敗例外を取得するが、パスワード認証

com.jcraft.jsch.JSchException: Auth fail 
    at com.jcraft.jsch.Session.connect(Session.java:484) 
    at com.jcraft.jsch.Session.connect(Session.java:162) 
    at ftptrial.main.TestTop.main(TestTop.java:52) 

を停止していませんJSchのバージョンは0.1.49に、それは正常に動作します。しかし私はその理由を理解することができません。 JSCH 0.1.48用

session = jsch.getSession(userName, hostName, portNumber); 
session.setPassword(password); 
session.connect(); 

ログイン:

INFO: Connecting to abc.defg.com port 22 
INFO: Connection established 
INFO: Remote version string: SSH-2.0-1.82_sshlib GlobalSCAPE 
INFO: Local version string: SSH-2.0-JSCH-0.1.48 
INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 
INFO: CheckKexes: diffie-hellman-group14-sha1 
INFO: diffie-hellman-group14-sha1 is not available. 
INFO: SSH_MSG_KEXINIT sent 
INFO: SSH_MSG_KEXINIT received 
INFO: kex: server: diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 
INFO: kex: server: ssh-rsa 
INFO: kex: server: twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc,3des-cbc,arcfour,cast128-cbc,aes256-cbc,aes128-cbc 
INFO: kex: server: twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc,3des-cbc,arcfour,cast128-cbc,aes256-cbc,aes128-cbc 
INFO: kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96 
INFO: kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96 
INFO: kex: server: zlib,none 
INFO: kex: server: zlib,none 
INFO: kex: server: 
INFO: kex: server: 
INFO: kex: client: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1 
INFO: kex: client: ssh-rsa,ssh-dss 
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc 
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc 
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96 
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96 
INFO: kex: client: none 
INFO: kex: client: none 
INFO: kex: client: 
INFO: kex: client: 
INFO: kex: server->client aes128-cbc hmac-md5 none 
INFO: kex: client->server aes128-cbc hmac-md5 none 
INFO: SSH_MSG_KEXDH_INIT sent 
INFO: expecting SSH_MSG_KEXDH_REPLY 
INFO: ssh_rsa_verify: signature true 
WARN: Permanently added 'abc.defg.com' (RSA) to the list of known hosts. 
INFO: SSH_MSG_NEWKEYS sent 
INFO: SSH_MSG_NEWKEYS received 
INFO: SSH_MSG_SERVICE_REQUEST sent 
INFO: SSH_MSG_SERVICE_ACCEPT received 
INFO: Authentications that can continue: publickey,keyboard-interactive,password 
INFO: Next authentication method: publickey 
INFO: Authentications that can continue: keyboard-interactive,password 
INFO: Next authentication method: keyboard-interactive 
INFO: Authentications that can continue: password 
INFO: Next authentication method: password 
INFO: Disconnecting from abc.defg.com port 22 
com.jcraft.jsch.JSchException: Auth fail 

ログインJSCH 0.1.54

INFO: Connecting to abc.defg.com port 22 
INFO: Connection established 
INFO: Remote version string: SSH-2.0-1.82_sshlib GlobalSCAPE 
INFO: Local version string: SSH-2.0-JSCH-0.1.54 
INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 
INFO: CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521 
INFO: diffie-hellman-group14-sha1 is not available. 
INFO: CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 
INFO: SSH_MSG_KEXINIT sent 
INFO: SSH_MSG_KEXINIT received 
INFO: kex: server: diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 
INFO: kex: server: ssh-rsa 
INFO: kex: server: twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc,3des-cbc,arcfour,cast128-cbc,aes256-cbc,aes128-cbc 
INFO: kex: server: twofish256-cbc,twofish-cbc,twofish128-cbc,blowfish-cbc,3des-cbc,arcfour,cast128-cbc,aes256-cbc,aes128-cbc 
INFO: kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96 
INFO: kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96 
INFO: kex: server: zlib,none 
INFO: kex: server: zlib,none 
INFO: kex: server: 
INFO: kex: server: 
INFO: kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 
INFO: kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc 
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc 
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96 
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96 
INFO: kex: client: none 
INFO: kex: client: none 
INFO: kex: client: 
INFO: kex: client: 
INFO: kex: server->client aes128-cbc hmac-md5 none 
INFO: kex: client->server aes128-cbc hmac-md5 none 
INFO: SSH_MSG_KEX_DH_GEX_REQUEST(1024<1024<1024) sent 
INFO: expecting SSH_MSG_KEX_DH_GEX_GROUP 
INFO: SSH_MSG_KEX_DH_GEX_INIT sent 
INFO: expecting SSH_MSG_KEX_DH_GEX_REPLY 
INFO: ssh_rsa_verify: signature true 
WARN: Permanently added 'abc.defg.com' (RSA) to the list of known hosts. 
INFO: SSH_MSG_NEWKEYS sent 
INFO: SSH_MSG_NEWKEYS received 
INFO: SSH_MSG_SERVICE_REQUEST sent 
INFO: SSH_MSG_SERVICE_ACCEPT received 
INFO: Authentications that can continue: publickey,keyboard-interactive,password 
INFO: Next authentication method: publickey 
INFO: Authentications that can continue: keyboard-interactive,password 
INFO: Next authentication method: keyboard-interactive 
INFO: Authentication succeeded (keyboard-interactive). 
Connection success 
+0

com.jcraft.jsch.JSchExceptionを参照してください:認証がcom.jcraft.jsch.Session.connectでcom.jcraft.jsch.Session.connect(Session.java:484) \tで \tに失敗(セッション.java:162) \t ftptrial.main.TestTop.main(TestTop.java:52) –

+1

エラーログは、コメントではなく質問本体に入れてください。 – rakwaht

+1

本当にこの質問に答えたいのであれば、両方のバージョンのJSchログファイルが必要です。質問は理にかなっていませんが。新しいバージョンが動作するので、何をしたいですか? - 特に最新のセキュリティ関連ライブラリを使用してください。 –

答えて

0

ためJSCH 0.1.48および0.1.49 JSCHはどちらも5歳です。それらを使用しないでください!

JSchの最新バージョン(0.1.54現在)を使用してください。


私はより多くの情報なしで決定的違いを説明することはできませんが、0.1.54が実際に成功した(0.1.48で失敗したパスワード認証と比較)キーボードインタラクティブ認証を使用するように、私はUserAuthKeyboardInteractive.startでこの変更を非難したい:

  • 0.1.48:

    prompt[0].toLowerCase().startsWith("password:")){ 
    
  • 0.1.49:

    prompt[0].toLowerCase().indexOf("password:") >= 0){ 
    

あなたのコードは実際にパスワード認証を試みています。しかし、JSchには経験談があります。キーボードインタラクティブ認証プロンプトで1つのパスワードを入力すると、パスワード認証ではなくキーボードの対話型認証が使用されます。

だから0.1.48 startsWithチェックが0.1.49以降ながら、プロンプトを取得しません:私は、プロンプトがサーバーから来ることを推測したい

ユーザーパスワードのようなものですindexOfを確認します。

このヒューリスティックに頼りたくない場合は、コードを実際にキーボード対話型認証を使用するように変更する必要があります。
http://www.jcraft.com/jsch/examples/UserAuthKI.java.html

+0

私は根本原因を知りたいと思っています。しかし、私は見つけることができません。 –

+0

あなたの質問が話題になっているのなら、疑問です。好奇心だけが尋ねる理由があれば。しかし、とにかく、ログファイルといくつかのコードが必要です。それ以外の場合、あなたの質問に答えることはできません! –

+0

セッション= jsch.getSession(ユーザー名、ホスト名、ポート番号); session.setPassword(password); プロパティconfig = new Properties(); config.put( "StrictHostKeyChecking"、 "no"); session.setConfig(config); session.setConfig( "StrictHostKeyChecking"、 "no"); session.connect(); –

関連する問題