Claus Ibsen created CAMEL-27619:
-----------------------------------
Summary: camel-jsch: known_hosts default fails,
keyboard-interactive, global logger, chmod, metadata
Key: CAMEL-27619
URL: https://issues.apache.org/jira/browse/CAMEL-27619
Project: Camel
Issue Type: Bug
Components: camel-jsch
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-jsch for CAMEL-23832 (PR
https://github.com/apache/camel/pull/30951).
These are separate problems of the component; the descriptions PR only
documents the current behavior.
h4. 1. The default useUserKnownHostsFile=true fails the connection when
~/.ssh/known_hosts does not exist
{{ScpOperations.createSession()}} uses {{<home>/.ssh/known_hosts}} when
{{knownHostsFile}} is not set and {{useUserKnownHostsFile}} is true (the
default). It loads the file with
{{ResourceHelper.resolveMandatoryResourceAsInputStream()}}, which throws when
the file is missing. The resulting {{GenericFileOperationFailedException}}
("Cannot load known host file") is not caught, so the producer cannot connect,
even with the default {{strictHostKeyChecking=no}}. A user on a host without a
known_hosts file (for example a container) must set
{{useUserKnownHostsFile=false}} or {{knownHostsFile}}.
Proposed change: decide whether a missing user known hosts file should mean "no
known hosts" (as when {{useUserKnownHostsFile=false}}), and otherwise give a
clear error message that names the option.
h4. 2. keyboard-interactive authentication with prompts never succeeds
{{ScpOperations.SessionUserInfo.promptKeyboardInteractive()}} always returns
{{null}}, and {{createSession()}} gives the password only through
{{UserInfo.getPassword()}}, never with {{Session.setPassword()}}. JSch answers
a single "password:" prompt from {{Session.setPassword()}} only, and otherwise
asks {{promptKeyboardInteractive()}}; a {{null}} answer cancels the method. So
keyboard-interactive is tried (it is in the JSch default
{{PreferredAuthentications}}) but fails, and an SSH server that offers only
keyboard-interactive for passwords (a common PAM setup) cannot be used with the
{{password}} option.
Proposed change: answer a password prompt with the configured {{password}} (or
set it on the session), or document that only {{password}} and {{publickey}}
authentication work.
h4. 3. verboseLogging and the JSch logger are global to the JVM
{{ScpComponent.initJsch()}} calls the static {{JSch.setLogger()}} when the
component starts. The logger of the last started SCP component, and its
{{verboseLogging}} setting, then apply to every JSch user in the JVM, such as
the sftp endpoints of camel-ftp, and their JSch messages are logged by the
{{ScpComponent}} logger.
Proposed change: set the logger per {{JSch}} instance
({{JSch.setInstanceLogger()}}) in {{createSession()}}.
h4. 4. An invalid chmod value is silently replaced by 664
{{ScpConfiguration.setChmod()}} replaces any value that is not three octal
digits (for example {{0644}} or {{rw-r--r--}}) by 664 without a log message or
an error, so the remote file gets other permissions than the user asked for.
Proposed change: fail the endpoint creation with an
{{IllegalArgumentException}}, or at least log a WARN.
h4. 5. certFile and certUri do the same thing
{{ScpOperations.resolveCertificateBytes()}} loads {{certFile}} and {{certUri}}
the same way (file system by default, {{classpath:}} prefix for the classpath);
{{certFile}} only takes precedence. Only {{certUri}} (and {{knownHostsFile}})
has {{supportFileReference = true}}.
Proposed change: keep one of them and deprecate the other, or make the metadata
consistent.
h4. 6. Options marked secret that hold no secret
{{knownHostsFile}}, {{certFile}}, {{certUri}}, {{certBytes}} and
{{preferredAuthentications}} in {{ScpConfiguration}} have {{security =
"secret"}}, so their values are masked in logs and tooling, although a known
hosts file, a certificate and a list of authentication methods are public.
Proposed change: remove {{security = "secret"}} from these options (keep it on
the password, the private key options and the passphrase).
h4. 7. Missing labels
{{verboseLogging}} of {{ScpComponent}} and {{chmod}} of {{ScpConfiguration}}
have no label, so they show up under common. {{chmod}} is a producer option,
{{verboseLogging}} could be {{advanced}}.
h4. 8. Inherited camel-ftp option texts do not fit scp
The options of {{RemoteFileConfiguration}} (camel-ftp) describe FTP: {{host}}
and {{port}} say "of the FTP server"; {{timeout}} says "Used only by
FTPClient", but the scp producer sets it as the JSch session timeout
({{session.setTimeout(config.getTimeout())}} in
{{ScpOperations.createSession()}}); {{soTimeout}} is not used by the scp
producer at all.
Proposed change: override these descriptions for scp, or exclude {{soTimeout}}
like the other FTP-only options in the {{excludeProperties}} of {{ScpEndpoint}}.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)