I'm trying to connect to an sftp server with a 'new' private key that starts with BEGIN OPENSSH PRIVATE KEY
(the 'old' version starts with BEGIN RSA PRIVATE KEY
).
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
When connecting with Camel SFTP (version 3.10), I get an error
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot connect to sftp://username1@localhost:55040
...
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@7c033a39
If I connect on the command line, it works as expected - the key is fine.
I found from this answer the error is caused by an outdated version of Jsch - but this was supposed to be fixed for Camel SSH in 3.10 https://issues.apache.org/jira/browse/CAMEL-16554, but I guess this doesn't affect sftp?
How can I connect?
There's sftp config to set 'ciphers' and 'keyExchangeProtocols' - are these relevant?
Stacktrace
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
dependencies
In the project pom I have
- org.apache.camel.springboot:camel-ftp-starter
- com.github.mwiede: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