[
https://issues.apache.org/jira/browse/CAMEL-27702?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-27702.
---------------------------------
Resolution: Fixed
Fixed in https://github.com/apache/camel/pull/31040 (merged to main as
d14db01867c8). Thanks Ayush0612005.
> camel-ssh: no-op channelOpenTimeout, idleTimeout 0, NPEs on channel open and
> missing key
> ----------------------------------------------------------------------------------------
>
> Key: CAMEL-27702
> URL: https://issues.apache.org/jira/browse/CAMEL-27702
> Project: Camel
> Issue Type: Bug
> Components: camel-ssh
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.24.0
>
>
> Found while improving the option descriptions of camel-ssh for CAMEL-23832
> (commit
> https://github.com/apache/camel/commit/9ac62b1d30b129bc58aaee56f706bceca8166952).
> These are separate problems of the component; the descriptions commit only
> documents the current behavior.
> h4. 1. channelOpenTimeout has no effect on the channel that runs the command
> {{SshUtils.createAndStartClient()}} sets
> {{CoreModuleProperties.CHANNEL_OPEN_TIMEOUT}}, which is the SSHD property
> {{ssh-agent-server-channel-open-timeout}}. In sshd-core 2.20.0 only the
> {{AgentServerProxy}} classes (SSH agent forwarding) read it. The wait for the
> exec or shell channel is {{openFuture.await(configuration.getTimeout())}} in
> {{SshHelper.sendExecCommand()}}, so a user who sets {{channelOpenTimeout}}
> sees no change.
> Use the value for the {{openFuture.await(...)}} call when it is set (falling
> back to {{timeout}}), or deprecate the option.
> h4. 2. idleTimeout cannot turn off the idle timeout of SSHD
> {{SshUtils.createAndStartClient()}} sets
> {{CoreModuleProperties.IDLE_TIMEOUT}} only for a value above 0, so with the
> default 0 the SSHD default of 10 minutes applies. A command that sends no
> data for 10 minutes has its session closed, and there is no value of the
> option that turns this off. The old option text said that 0 means no idle
> timeout.
> Pass 0 (or a negative value) through to SSHD so that it turns the idle
> timeout off, or document a value for that and give the option a real default
> value.
> h4. 3. NullPointerException when the channel does not open within the timeout
> In {{SshHelper.sendExecCommand()}}, when {{openFuture.isOpened()}} is false
> after {{openFuture.await(timeout)}} (the channel did not open in time, or the
> server refused it), {{result}} stays null and is returned.
> {{SshProducer.process()}} then calls {{result.getStdout()}} and fails with
> {{CamelExchangeException: Cannot execute command}} caused by a
> {{NullPointerException}}; {{SshConsumer.poll()}} fails the same way.
> Throw an exception that says the channel did not open within the timeout,
> with the cause from the open future.
> h4. 4. NullPointerException "No key-pair to add" when no key pair is found
> When {{certResource}} cannot be read or parsed,
> {{ResourceHelperKeyPairProvider.loadKeys()}} logs a WARN and returns an empty
> list. When {{keyType}} matches no key pair, {{KeyPairProvider.loadKey()}}
> returns null. In both cases {{SshHelper.sendExecCommand()}} passes null to
> {{ClientSession.addPublicKeyIdentity()}}, which fails with
> {{NullPointerException: No key-pair to add}} after the connection is made.
> Check for a null key pair and throw an exception that names {{certResource}}
> or {{keyType}}.
> h4. 5. A channelType other than exec or shell fails each exchange with a
> NullPointerException
> {{SshHelper.sendExecCommand()}} only creates a channel for {{exec}} and
> {{shell}}; for another value {{channel}} stays null and {{channel.setIn(in)}}
> throws a {{NullPointerException}} after connecting and authenticating.
> {{SshEndpoint.doStart()}} only checks {{shellPrompt}} for {{shell}}.
> Reject other values in {{SshEndpoint.doStart()}}, and add {{enums =
> "exec,shell"}} to the option.
> h4. 6. A consumer without pollCommand starts, then every poll fails
> {{SshConsumer.poll()}} passes a null {{pollCommand}} to
> {{SshHelper.sendExecCommand()}}, which connects and authenticates, and then
> {{ChannelExec}} fails with {{IllegalArgumentException: Command may not be
> null/empty}} (with {{channelType=shell}}, a {{NullPointerException}} on
> {{command.getBytes()}}). This repeats at every poll.
> Fail at the start of the consumer when {{pollCommand}} is not set.
> h4. 7. The authentication failure message names the wrong user
> {{SshHelper.sendExecCommand()}} throws {{Failed to authenticate username}}
> with {{configuration.getUsername()}}, also when the {{CamelSshUsername}}
> header gave the user name that was used.
> Use the resolved {{userName}} in the message.
> h4. 8. kex ignores the registered key exchange extensions
> {{SshUtils.configureKexAlgorithms()}} reads
> {{BuiltinDHFactories.getRegisteredExtensions()}} into {{dhFactories}} but
> never uses it, and matches the names only against
> {{BuiltinDHFactories.VALUES}}. A key exchange registered as an extension is
> skipped with the warning {{Configured KeyExchangeFactory '...' not
> available}}. The other algorithm options ({{ciphers}}, {{macs}},
> {{signatures}}, {{compressions}}) do include the registered extensions. The
> method also logs the list of available algorithms at INFO, where the others
> use TRACE.
> Add the registered extensions to the list, as the other {{configure...}}
> methods do, and log at TRACE.
> h4. 9. Metadata: the headers have no label
> {{CamelSshUsername}} and {{CamelSshPassword}} are read only by the producer,
> and {{CamelSshStderr}} and {{CamelSshExitValue}} are set by the producer and
> the consumer, but the {{@Metadata}} of {{SshConstants}} has no {{label}}.
> Add {{label = "producer"}} to the first two and {{label =
> "consumer,producer"}} to the others.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)