This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch fix/CAMEL-24097
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6e415c9405132daf510dcc211e2ef535d5c74fb7
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Jul 16 07:56:44 2026 +0200

    CAMEL-24097: camel-ftp - SFTP knownHostsUri/knownHosts silently clobbered 
by unconditional ~/.ssh/known_hosts fallback
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../java/org/apache/camel/component/file/remote/SftpOperations.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
index 56492191b0c9..41ffa9a85a31 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
@@ -333,7 +333,8 @@ public class SftpOperations implements 
RemoteFileOperations<SftpRemoteFile> {
         }
 
         String knownHostsFile = sftpConfig.getKnownHostsFile();
-        if (knownHostsFile == null && sftpConfig.isUseUserKnownHostsFile()) {
+        if (knownHostsFile == null && 
!isNotEmpty(sftpConfig.getKnownHostsUri())
+                && sftpConfig.getKnownHosts() == null && 
sftpConfig.isUseUserKnownHostsFile()) {
             knownHostsFile = HomeHelper.resolveHomeDir() + "/.ssh/known_hosts";
             LOG.info("Known host file not configured, using user known host 
file: {}", knownHostsFile);
         }

Reply via email to