Apache Camel SFTP:"JSchException: invalid privatekey: [B@7c033a39" with OpenSSH 私钥



我正在尝试使用以BEGIN OPENSSH PRIVATE KEY开头的"新"私钥连接到sftp服务器("旧"版本以BEGIN RSA PRIVATE KEY开头(。

-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----

当连接Camel SFTP(3.10版(时,我得到一个错误

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot connect to sftp://username1@localhost:55040
...
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@7c033a39

如果我在命令行上连接,它会按预期工作——密钥很好。

我从这个答案中发现,错误是由过时的Jsch版本引起的,但这本应在3.10中为Camel SSH修复https://issues.apache.org/jira/browse/CAMEL-16554,但我想这不会影响sftp?

如何连接?

有sftp配置来设置"ciphers"one_answers"keyExchangeProtocols"-这些相关吗?


堆栈跟踪
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot connect to sftp://username1@localhost:55040
at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:158) ~[camel-ftp-3.10.0.jar:3.10.0]
at org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:235) ~[camel-ftp-3.10.0.jar:3.10.0]
at org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:77) ~[camel-ftp-3.10.0.jar:3.10.0]
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:128) ~[camel-file-3.10.0.jar:3.10.0]
at org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:190) [camel-support-3.10.0.jar:3.10.0]
at org.apache.camel.support.ScheduledPollConsumer.run(ScheduledPollConsumer.java:107) [camel-support-3.10.0.jar:3.10.0]
at org.apache.camel.pollconsumer.quartz.QuartzScheduledPollConsumerJob.execute(QuartzScheduledPollConsumerJob.java:61) [camel-quartz-3.10.0.jar:3.10.0]
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.3.2.jar:?]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.3.2.jar:?]
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@7c033a39
at com.jcraft.jsch.KeyPair.load(KeyPair.java:664) ~[jsch-0.1.55.jar:?]
at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:46) ~[jsch-0.1.55.jar:?]
at com.jcraft.jsch.JSch.addIdentity(JSch.java:441) ~[jsch-0.1.55.jar:?]
at org.apache.camel.component.file.remote.SftpOperations.createSession(SftpOperations.java:233) ~[camel-ftp-3.10.0.jar:3.10.0]
at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:125) ~[camel-ftp-3.10.0.jar:3.10.0]
... 8 more
依赖项

在项目pom我有

  • org.apache.cocamel.springboot:ccamel ftp启动器
  • com.github.mviede:jsch:0.1.63
mvn dependency:tree -Dincludes=com.jcraft:jsch
[INFO] Scanning for projects...
[INFO] 
[INFO] --------< com.project >---------
[INFO] Building com.project
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) @ com.project ---
[INFO] com.project:jar:${sha1}
[INFO] - org.apache.camel.springboot:camel-ftp-starter:jar:3.10.0:compile
[INFO]    - org.apache.camel:camel-ftp:jar:3.10.0:compile
[INFO]       - com.jcraft:jsch:jar:0.1.55:compile

要替换由camelftp-starter引入的Jsch库,可以使用exclude标记,如下所示:

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- First define the library of jsch fork -->
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>jsch</artifactId>
<version>0.1.63</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-ftp-starter</artifactId>
<version>3.9.0</version>
<!-- exclude original jsch -->
<exclusions>
<exclusion>
<artifactId>jsch</artifactId>
<groupId>com.jcraft</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

请确保没有其他依赖项拉取jcraft.jsch工件。

相关内容

  • 没有找到相关文章

最新更新