Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorithm negotiation fail when connect the server #68

Open
wdquan1985 opened this issue Jan 4, 2018 · 9 comments
Open

Algorithm negotiation fail when connect the server #68

wdquan1985 opened this issue Jan 4, 2018 · 9 comments

Comments

@wdquan1985
Copy link

wdquan1985 commented Jan 4, 2018

When I execute the following code, there are a Algorithm negotiation fail exception.
Shell shell = new SSH(serverIP, 22, userName, password);
String stdout = new Shell.Plain(shell).exec("echo 'Hello, world!'");

The following is the error info.
java.io.IOException: com.jcraft.jsch.JSchException: Algorithm negotiation fail
at com.jcabi.ssh.SSH.session(SSH.java:272)
at com.jcabi.ssh.AbstractSSHShell.exec(AbstractSSHShell.java:98)
at com.jcabi.ssh.SSH.exec(SSH.java:76)
at com.jcabi.ssh.Shell$Plain.exec(Shell.java:172)
at com.dashboard.service.DeployJobsServiceImpl.getDeployServerInfo(DeployJobsServiceImpl.java:784)
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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy134.getDeployServerInfo(Unknown Source)
at com.dashboard.service.inter.DeployJobsServiceTest.testGetDeployServerInfo(DeployJobsServiceTest.java:102)
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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
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.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
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:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.jcraft.jsch.JSchException: Algorithm negotiation fail
at com.jcraft.jsch.Session.receive_kexinit(Session.java:583)
at com.jcraft.jsch.Session.connect(Session.java:320)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.jcabi.ssh.SSH.session(SSH.java:268)
... 48 more

@0crat
Copy link

0crat commented Jan 4, 2018

@yegor256 please, pay attention to this issue

@wdquan1985
Copy link
Author

wdquan1985 commented Jan 4, 2018

Shell shell = new SSH(serverIP, 22, userName, password);
String stdout = new Shell.Plain(shell).exec("echo 'Hello, world!'");
The password is a private key:
String password= "-----BEGIN RSA PRIVATE KEY-----" + "\n" + "MIIEowIBAAKCAQEA+wQzLRBZB+/2EKdGF+eezckkbz3+ahROnxJr8rx9VhbyQvf3" + "\n" + "T9CQz1mWaY3czdgHFRcESsC1bumfUMxO3z1bkfk/mcWBh9vPS6sRDqb+zj8BypIE" + "\n" + "bOC4YtclKQjH6dJ0avBrENZbcoL0BLN4VHATq/vcxuXNT9/ktXXHxAcahrIMDj/d" + "\n" + "m8CXABzlAdprvLjffjN2aW+IUsvIbNfp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GtQxU9qPCOn439uk+6NKvt0Nm4L5K1inAVHAWfLjyH2VcdrZnftgSmv3ffzV" + "\n" + "yg1n4kZBl5RHjD0eL0SoGQKBgD2Wc1xut7N7sLHZRhK26CNvh5SHgpht6lBNN04n" + "\n" + "sB0VkgQ1or1efUZQoEu5x58utUWyyxmFtCRDTztZtn3wgAskDHfLqZTfXX1fSl96" + "\n" + "EgLHT7FdDnw+IC5VPCaOtISIAftHeg5sBcxQM1O9gGeZBaW4oXlSIB12z6ISsRBy" + "\n" + "AeDhAoGBANIgCmuzvD7Ahyg+E2YUqnbCMpt4wm+gmxaYjhhxREGzz/Dhho0iUNLo" + "\n" + "lsq63mlj29uZlisJRibIyJfdpSsFoECaDC2n/vxHDbun8Ro8yqDIN6tO6PZBRj7u" + "\n" + "7HpdSktQ/usTt1mAU32mkGEvVQAmNiVVqdpdKrW7w2ZH0rYICMKd" + "\n" + "-----END RSA PRIVATE KEY-----";

@wdquan1985
Copy link
Author

When I use a URL which define the private key file. the same error.
URL keyUrl = new URL("file:/u/bwang018/.ssh/privateKey");
shell = new SSH(serverIP,22,userName,keyUrl);
String stdout = new Shell.Plain(shell).exec("ifconfig");

@wdquan1985
Copy link
Author

wdquan1985 commented Jan 4, 2018

If I only use the following dependency which is used by the jcabi project, there is no connection error.
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>

The test code:
JSch jsch = new JSch();
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
jsch.addIdentity( the private key file path);
session=jsch.getSession(userName, host, port);
session.setConfig(config);
session.connect();

@vlohana
Copy link

vlohana commented Jan 4, 2018

wdquan1985 - As per your above comment
The test code:

JSch jsch = new JSch();
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
jsch.addIdentity( the private key file path);
session=jsch.getSession(userName, host, port);
session.setConfig(config);
session.connect();

For JDK_1.8_131 it runs swiftly but when I use version above > JDK_1.8_131 I get this error
Anyone else facing the similar issue.

I even tried updating the /etc/ssh/sshd_config and restarted on the linux machine I want to access but I am still getting the

com.jcraft.jsch.JSchException: Algorithm negotiation fail
   at com.jcraft.jsch.Session.receive_kexinit(Session.java:590)

Can anyone help on this ? please

@yegor256
Copy link
Member

yegor256 commented Jan 8, 2018

@wdquan1985 I don't know what's going on. I think we should report it to jSch and see what they say.

@wdquan1985
Copy link
Author

@vlohana @yegor256 ,my java version is:
C:\windows\system32>java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

@laurafchen
Copy link

same error as @vlohana, anyone have insights

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)

@vlohana
Copy link

vlohana commented Apr 13, 2018

My Issue got resolved as I did following to resolve

  1. Updated JDK to JDK 1.8_161
  2. Updated the JCE with Unlimited Strength (googling the same can help)
  3. Removed any firewall policy like services iptables stop

That resolved my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants