我尝试使用以下代码建立与SFTP服务器的连接(之前工作正常),但最近我正面临如下所示的错误日志 -
信息 - 使用以下版本
使用以下代码 -
JSch jsch = new JSch();
Properties configuration = new Properties();
configuration.put("cipher.s2c",
"aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc");
configuration.put("cipher.c2s",
"aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc");
configuration.put("kex", "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256");
Session session = jsch.getSession(user , host, port);
session.setPassword(pwd);
session.setConfig(configuration);
System.out.println("------------------>Establishing Connection...");
session.connect();
System.out.println("------------------>Connection established.");
System.out.println("------------------>Creating SFTP Channel.");
ChannelSftp sftpChannel = (ChannelSftp) session.openChannel("sftp");
sftpChannel.connect();
System.out.println("------------------>SFTP Channel created.");
预期 - 应成功连接到服务器
实际 - 获得以下错误 -
com.jcraft.jsch.JSchException: Algorithm negotiation fail
at com.jcraft.jsch.Session.receive_kexinit(Session.java:590)
at com.jcraft.jsch.Session.connect(Session.java:320)
at com.jcraft.jsch.Session.connect(Session.java:183)
at FunctionLib.StoreAllRecordsFromLOCAL_IntoRequestList_Test(FunctionLib.java:38)
at TestJunit.testConnectivity(TestJunit.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
日志文件:
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: CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
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-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256@ssh.com,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
INFO: kex: server: ssh-rsa,ssh-rsa-sha256@ssh.com
INFO: kex: server: aes256-cbc,seed-cbc@ssh.com,crypticore128@ssh.com
INFO: kex: server: aes256-cbc,seed-cbc@ssh.com,crypticore128@ssh.com
INFO: kex: server: hmac-sha1,hmac-md5,crypticore-mac@ssh.com
INFO: kex: server: hmac-sha1,hmac-md5,crypticore-mac@ssh.com
INFO: kex: server: none,zlib
INFO: kex: server: none,zlib
INFO: kex: server:
INFO: kex: server:
INFO: kex: client: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
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
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-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: Disconnecting from 10.92.155.57 port 22
使用Wifi运行时记录 - (连接成功建立) -
Dec 12, 2017 6:14:35 PM FunctionLib$MyJSchLogger log
INFO: Connecting to 10.92.155.6 port 22
Dec 12, 2017 6:14:35 PM FunctionLib$MyJSchLogger log
INFO: Connection established
Dec 12, 2017 6:14:35 PM FunctionLib$MyJSchLogger log
INFO: Remote version string: SSH-2.0-6.4.10.264 SSH Tectia Server
Dec 12, 2017 6:14:35 PM FunctionLib$MyJSchLogger log
INFO: Local version string: SSH-2.0-JSCH-0.1.54
Dec 12, 2017 6:14:35 PM FunctionLib$MyJSchLogger log
INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
Dec 12, 2017 6:14:36 PM FunctionLib$MyJSchLogger log
INFO: aes256-ctr is not available.
Dec 12, 2017 6:14:36 PM FunctionLib$MyJSchLogger log
INFO: aes192-ctr is not available.
Dec 12, 2017 6:14:36 PM FunctionLib$MyJSchLogger log
INFO: aes256-cbc is not available.
Dec 12, 2017 6:14:36 PM FunctionLib$MyJSchLogger log
INFO: aes192-cbc is not available.
Dec 12, 2017 6:14:36 PM FunctionLib$MyJSchLogger log
INFO: CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_KEXINIT sent
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_KEXINIT received
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256@ssh.com,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server: ssh-rsa,ssh-rsa-sha256@ssh.com
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server: crypticore128@ssh.com,aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,3des-cbc
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server: crypticore128@ssh.com,aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,3des-cbc
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server: crypticore-mac@ssh.com,hmac-sha1,hmac-sha1-96,hmac-sha2-256,hmac-sha256-2@ssh.com,hmac-sha224@ssh.com,hmac-sha256@ssh.com,hmac-sha384@ssh.com,hmac-sha2-512,hmac-sha512@ssh.com
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server: crypticore-mac@ssh.com,hmac-sha1,hmac-sha1-96,hmac-sha2-256,hmac-sha256-2@ssh.com,hmac-sha224@ssh.com,hmac-sha256@ssh.com,hmac-sha384@ssh.com,hmac-sha2-512,hmac-sha512@ssh.com
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server: none,zlib
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server: none,zlib
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server:
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server:
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client: none
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client: none
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client:
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client:
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: server->client aes128-ctr hmac-sha1 none
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: kex: client->server aes128-ctr hmac-sha1 none
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_KEXDH_INIT sent
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: expecting SSH_MSG_KEXDH_REPLY
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: ssh_rsa_verify: signature true
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
WARNING: Permanently added '10.92.155.6' (RSA) to the list of known hosts.
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_NEWKEYS sent
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_NEWKEYS received
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_SERVICE_REQUEST sent
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_SERVICE_ACCEPT received
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: Authentications that can continue: publickey,keyboard-interactive,password
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: Next authentication method: publickey
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: Authentications that can continue: password
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: Next authentication method: password
Dec 12, 2017 6:14:37 PM FunctionLib$MyJSchLogger log
INFO: Authentication succeeded (password).
使用LAN运行时记录 - (未建立连接) -
Dec 12, 2017 6:12:36 PM FunctionLib$MyJSchLogger log
INFO: Connecting to 10.92.155.6 port 22
Dec 12, 2017 6:12:36 PM FunctionLib$MyJSchLogger log
INFO: Connection established
Dec 12, 2017 6:12:36 PM FunctionLib$MyJSchLogger log
INFO: Remote version string: SSH-2.0-6.4.10.264 SSH Tectia Server
Dec 12, 2017 6:12:36 PM FunctionLib$MyJSchLogger log
INFO: Local version string: SSH-2.0-JSCH-0.1.54
Dec 12, 2017 6:12:36 PM FunctionLib$MyJSchLogger log
INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
Dec 12, 2017 6:12:37 PM FunctionLib$MyJSchLogger log
INFO: aes256-ctr is not available.
Dec 12, 2017 6:12:37 PM FunctionLib$MyJSchLogger log
INFO: aes192-ctr is not available.
Dec 12, 2017 6:12:37 PM FunctionLib$MyJSchLogger log
INFO: aes256-cbc is not available.
Dec 12, 2017 6:12:37 PM FunctionLib$MyJSchLogger log
INFO: aes192-cbc is not available.
Dec 12, 2017 6:12:37 PM FunctionLib$MyJSchLogger log
INFO: CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_KEXINIT sent
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: SSH_MSG_KEXINIT received
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256@ssh.com,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server: ssh-rsa,ssh-rsa-sha256@ssh.com
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server: aes256-cbc,seed-cbc@ssh.com,crypticore128@ssh.com
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server: aes256-cbc,seed-cbc@ssh.com,crypticore128@ssh.com
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server: hmac-sha1,hmac-md5,crypticore-mac@ssh.com
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server: hmac-sha1,hmac-md5,crypticore-mac@ssh.com
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server: none,zlib
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server: none,zlib
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server:
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: server:
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client: none
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client: none
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client:
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: kex: client:
Dec 12, 2017 6:12:38 PM FunctionLib$MyJSchLogger log
INFO: Disconnecting from 10.92.155.6 port 22
答案 0 :(得分:-1)
对于上述问题,我做了以下内容 -
更新了以下内容 - Java - 1.8.151 日食 - 氧气
安装JDK后,我用这个文件更新了folderC:/ProgramFiles/Java/jre1.8.151/jre/lib/security/中存在的策略文件(local_policy.jar& US_export_policy.jar) - > Java密码术扩展(JCE)无限强度管辖政策文件8
上面的一条评论中已经提到了下载文件的链接。