Camel sftp endpoint with "strictHostKeyChecking=yes" option failed after SFTP server changed its IP address

Solution Unverified - Updated -

Issue

We have JBoss Fuse container running Camel. There is a Camel SFTP endpoint configured with the following parameters:

knownHostsFile=/home/fuse/.ssh/known_hosts&strictHostKeyChecking=yes

Recently, the sftp server changed the IP address, and we also had to restart the container. We are not sure what was first, probably the IP change was first, then the container restart.

After the container restart, Camel was no longer able to connect to the server:

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot connect to sftp://xxxx@xxx.com:22
        at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:143)[119:org.apache.camel.camel-ftp:2.12.0.redhat-611423]
        at org.apache.camel.component.file.remote.RemoteFileProducer.connectIfNecessary(RemoteFileProducer.java:189)[119:org.apache.camel.camel-ftp:2.12.0.redhat-611423]
        at org.apache.camel.component.file.remote.RemoteFileProducer.recoverableConnectIfNecessary(RemoteFileProducer.java:181)[119:org.apache.camel.camel-ftp:2.12.0.redhat-611423]
        at org.apache.camel.component.file.remote.RemoteFileProducer.preWriteCheck(RemoteFileProducer.java:113)[119:org.apache.camel.camel-ftp:2.12.0.redhat-611423]
        at org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:114)[115:org.apache.camel.camel-core:2.12.0.redhat-611423]
...
        at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114)[115:org.apache.camel.camel-core:2.12.0.redhat-611423]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_75]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)[:1.7.0_75]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)[:1.7.0_75]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.7.0_75]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_75]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_75]
        at java.lang.Thread.run(Thread.java:745)[:1.7.0_75]
Caused by: com.jcraft.jsch.JSchException: reject HostKey: xxx.com
        at com.jcraft.jsch.Session.checkHost(Session.java:748)[64:org.apache.servicemix.bundles.jsch:0.1.49.1]
        at com.jcraft.jsch.Session.connect(Session.java:321)[64:org.apache.servicemix.bundles.jsch:0.1.49.1]
        at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:115)[119:org.apache.camel.camel-ftp:2.12.0.redhat-611423]
... 

Then we tried to log in manually from the command line, with success. After this, Camel recovered by itself.

[fuse@meldc1esb92]$ sftp xxx.com
Connecting to xxx.com...
Warning: Permanently added the RSA host key for IP address 'xx.xxx.xxx.xx' to the list of known hosts.

It looks like the Camel could not connect because of this warning (Permanently added the RSA host key …), and after the host key was added to the known hosts file, it was able to connect. Please note - RSA host key did not change. Only IP address for the server zzz.com has changed.

Can you confirm if this is expected behaviour, or a Camel/JSCH bug? Also, is it possible to disable this IP checking? We still need RSA key checking, but we connect to the server using domain name, and don’t want to rely on the IP address to be static.

Environment

  • JBoss Fuse
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content