我正在尝试通过驼峰路由执行ssh命令。我到了下面 任何人都可以帮助我解决问题。我能够使用用户名和密码执行命令。
我在服务器的authorized_keys中复制了公钥。 我正在使用蓝图dsl。
< to uri="ssh://admin@10.23.24.41:22? certResource=classpath:test_rsa&timeout=5000"/>
test_rsa是存在公钥的文件名。
Server at /10.23.24.41:22 presented unverified DSA key:
8a:40:91:2a:16:90:8c:c4:06:b1:1f:79:74:2f:08:09
EXCEPTION MESSAGEstrong text=Cannot execute command:
ls /opt/esb/jboss-fuse-6.2.1.redhat-084. Exchange[Message:
ls /opt/esb/jboss-fuse-6.2.1.redhat-084]. Caused by: [java.io.IOException - Error performing public key authentication]
STACKTRACE=org.apache.camel.CamelExchangeException: Cannot execute command:
ls /opt/esb/jboss-fuse-6.2.1.redhat-084. Exchange[Message:
ls /opt/esb/jboss-fuse-6.2.1.redhat-084]. Caused by: [java.io.IOException - Error performing public key authentication]
at org.apache.camel.component.ssh.SshProducer.process(SshProducer.java:64)
at org.apache.camel.util.AsyncProcessorConverterHelperProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)atorg.apache.camel.processor.SendProcessor.process(SendProcessor.java:139)atorg.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)atorg.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)atorg.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)atorg.apache.camel.processor.Pipeline.process(Pipeline.java:121)atorg.apache.camel.processor.Pipeline.process(Pipeline.java:83)atorg.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)atorg.apache.camel.component.directvm.DirectVmProcessor.process(DirectVmProcessor.java:55)atorg.apache.camel.component.directvm.DirectVmProducer.process(DirectVmProducer.java:55)atorg.apache.camel.processor.SendProcessor.process(SendProcessor.java:139)atorg.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)atorg.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)atorg.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)atorg.apache.camel.processor.Pipeline.process(Pipeline.java:121)atorg.apache.camel.processor.Pipeline.process(Pipeline.java:83)atorg.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)atorg.apache.camel.component.cxf.CxfConsumer1.asyncInvoke(CxfConsumer.java:95)
at org.apache.camel.component.cxf.CxfConsumer1.invoke(CxfConsumer.java:75)atorg.apache.cxf.interceptor.ServiceInvokerInterceptor1.run(ServiceInvokerInterceptor.java:59)
at java.util.concurrent.ExecutorsRunnableAdapter.call(Executors.java:511)atjava.util.concurrent.FutureTask.run(FutureTask.java:266)atorg.apache.cxf.interceptor.ServiceInvokerInterceptor2.run(ServiceInvokerInterceptor.java:126)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:251)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:261)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1088)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1024)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:984)
at org.eclipse.jetty.server.AbstractHttpConnectionRequestHandler.content(AbstractHttpConnection.java:1045)atorg.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)atorg.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:236)atorg.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)atorg.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)atorg.eclipse.jetty.io.nio.SelectChannelEndPoint1.run(SelectChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Error performing public key authentication
at org.apache.sshd.client.auth.deprecated.UserAuthPublicKey.next(UserAuthPublicKey.java:90)
at org.apache.sshd.client.session.ClientUserAuthServiceOld.processUserAuth(ClientUserAuthServiceOld.java:150)
at org.apache.sshd.client.session.ClientUserAuthServiceOld.auth(ClientUserAuthServiceOld.java:183)
at org.apache.sshd.client.session.ClientUserAuthService.auth(ClientUserAuthService.java:109)
at org.apache.sshd.client.session.ClientSessionImpl.tryAuth(ClientSessionImpl.java:182)
at org.apache.sshd.client.session.ClientSessionImpl.authPublicKey(ClientSessionImpl.java:173)
at org.apache.camel.component.ssh.SshHelper.sendExecCommand(SshHelper.java:82)
at org.apache.camel.component.ssh.SshProducer.process(SshProducer.java:59)
… 47 more
Caused by: java.lang.NullPointerException
at org.apache.sshd.common.util.KeyUtils.getKeyType(KeyUtils.java:67)
at org.apache.sshd.client.auth.deprecated.UserAuthPublicKey.next(UserAuthPublicKey.java:61)
… 54 more
答案 0 :(得分:1)
我忘了在类路径中添加test_rsa作为私钥和test_rsa.pub。添加后我能够与服务器通信。 enter image description here
答案 1 :(得分:0)
而不是certResource = classpath:test_rsa, 尝试:privateKeyFile = / path / to / test_rsa
&LT; to uri =“ssh://admin@10.23.24.41:22?privateKeyFile = / path / to / test_rsa&amp; amp; knownHostsFile = / path / to / known_hosts”/&gt;
您的known_hosts文件最初可能为空。 这对我有用。希望这有帮助!