寻找jsch-0.1.55.jar替代方案:解决SSH算法协商失败问题
问题描述
背景
我对相关技术较为陌生,对术语使用可能存在混淆,若有误用敬请谅解。
我在维护部署于服务器1的Grails应用,该应用原本依赖jsch-0.1.55.jar,需要通过SSH与服务器2(Red Hat Enterprise Linux Server 7.9)通信。近期服务器2修改了SSH配置,强制要求使用hmac-md5和aes256-cbc算法进行通信。
临时解决方案
目前我们的临时解决办法是删除服务器2/etc/ssh/sshd_config中的以下配置行:
Ciphers aes256-ctr,aes192-ctr,aes128-ctr MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com KexAlgorithms diffie-hellman-group-exchange-sha256
但我们需要在恢复这些配置行的前提下实现正常通信。
当前故障
现在应用的build.gradle已经引入com.github.mwiede:jsch:0.2.4依赖,但仍出现算法协商失败的错误,错误日志如下:
Job GRAILS_JOBS.refresh.ReflogsJob threw a JobExecutionException: org.quartz.JobExecutionException: : com.jcraft.jsch.JSchException: Algorithm negotiation fail at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:111) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) Caused by: org.apache.tools.ant.BuildException: com.jcraft.jsch.JSchException: Algorithm negotiation fail at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:336) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) 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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at groovy.util.AntBuilder.performTask(AntBuilder.java:333) at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:278) at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:151) at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:213) at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:43) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127) at refresh.ReflogsJob.getLogs(ReflogsJob.groovy:66) at refresh.ReflogsJob.execute(ReflogsJob.groovy:39) 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 grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:104) ... 2 common frames omitted Caused by: 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 org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:279) at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:312) ... 24 common frames omitted Job GRAILS_JOBS.refresh.ReftasksJob threw a JobExecutionException: org.quartz.JobExecutionException: : com.jcraft.jsch.JSchException: Algorithm negotiation fail at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:111) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) Caused by: org.apache.tools.ant.BuildException: com.jcraft.jsch.JSchException: Algorithm negotiation fail at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:336) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) 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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at groovy.util.AntBuilder.performTask(AntBuilder.java:333) at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:278) at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:151) at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:213) at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:43) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127) at refresh.SshService.$tt__connectTo(SshService.groovy:52) 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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1217) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:1011) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:994) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethodSafe(InvokerHelper.java:97) at refresh.SshService$_connectTo_closure2.doCall(SshService.groovy) 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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041) at groovy.lang.Closure.call(Closure.java:405) at groovy.lang.Closure.call(Closure.java:421) at grails.gorm.transactions.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:94) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) at grails.gorm.transactions.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:91) at refresh.SshService.connectTo(SshService.groovy) 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.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:179) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:70) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115) at refresh.ReftasksJob$_execute_closure1.doCall(ReftasksJob.groovy:50) 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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041) at groovy.lang.Closure.call(Closure.java:405) at groovy.lang.Closure.call(Closure.java:421) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2296) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2281) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2322) at org.codehaus.groovy.runtime.dgm$186.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:244) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127) at refresh.ReftasksJob.execute(ReftasksJob.groovy:40) 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 grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:104) ... 2 common frames omitted Caused by: 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 org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:279) at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:312) ... 79 common frames omitted
需求
寻求jsch-0.1.55.jar的合适替代方案,使其支持hmac-md5和aes256-cbc算法,恢复与服务器2的SSH通信。
内容的提问来源于stack exchange,提问作者Rogelio Cordova
相关产品推荐
相关产品推荐

