1

I use Camel DSL route definition:

@Component
public class UploadRoutesDefinition extends RouteBuilder {
  ...
  @Override
    public void configure() throws Exception {

    ```
        from(String.format("sftp://%s@%s:%d/%s?password=%s&delete=true&readLock=changed&delay=%s"
        ...

When I put file into sftp folder I see following logs:

20/03/2018 14:02:4420.03.18 14:02:44.193 [Camel (My_Service) thread #3 - seda://parsed_csv] INFO  o.a.c.c.file.remote.SftpOperations - Known host file not configured, using user known host file: /home/gradle/.ssh/known_hosts
20/03/2018 14:02:4420.03.18 14:02:44.300 [Camel (MIS_UploadService) thread #3 - seda://parsed_csv] WARN  o.a.c.c.file.remote.SftpOperations - JSCH -> Permanently added 'sftp' (RSA) to the list of known hosts.
20/03/2018 14:02:4420.03.18 14:02:44.300 [Camel (MIS_UploadService) thread #3 - seda://parsed_csv] WARN  o.a.c.c.file.remote.SftpOperations - Server asks for confirmation (yes|no): /home/gradle/.ssh/known_hosts does not exist.
20/03/2018 14:02:44Are you sure you want to create it?. Camel will answer no.
```

I want to disable host verification.

Looks like adding &useUserKnownHostsFile=false to the path resolves my error. But I have a lot of route definitions and I don't like to add this suffix to each URL. Can I disable this verification globally?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • why could add all the servers to `.ssh/known_hosts` file yourself, so that camel recognizes this as known host – pvpkiran Mar 22 '18 at 10:15
  • @pvpkiran, client often changes the sftp server urls and don't want to do any manipulaion except changing URL, login and password – gstackoverflow Mar 22 '18 at 10:20
  • how about looping on all sftp endpoints and use java api to disable it: ((SftpEndpoint)endpoint).getConfiguration().setUseUserKnownHostsFile(false) to – mwpeng 彭明伟 May 03 '21 at 06:02

1 Answers1

1

You cannot configure this globally. But as its java code its easy to use Camel's property placeholder to have a global ftp url you can use as base, or in your Camel route its also just Java code, so the string formatter you do, can use a base string that has the option turned on you then use with string concat etc.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65