Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 121. SSH
SSH 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Available as of Camel 2.10
The SSH component enables access to SSH servers such that you can send an SSH command, and process the response.
Maven users will need to add the following dependency to their
pom.xml
for this component:
URI format 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
ssh:[username[:password]@]host[:port][?options]
ssh:[username[:password]@]host[:port][?options]
Options 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Name | Default Value | Description |
---|---|---|
host
|
Hostname of SSH Server | |
port
|
22
|
Port of the SSH Server |
username
|
Username used for authenticating with SSH Server. | |
password
|
Password used for authenticating with SSH Server. Used if keyPairProvider is null.
|
|
keyPairProvider
|
Refers to a org.apache.sshd.common.KeyPairProvider to use for loading keys for authentication. If this option is used, then password is not used.
|
|
keyType
|
ssh-rsa
|
Refers to a key type to load from keyPairProvider . The key types can for example be "ssh-rsa" or "ssh-dss".
|
certResource
|
null
|
Camel 2.11: Path reference to a public key certificate. Prefix path with classpath: , file: , or http: .
|
certFilename
|
null
|
@deprecated: Use certResource instead. Refers to a filename to use within file based keyPairProvider .
|
timeout
|
30000
|
Milliseconds to wait beforing timing out connection to SSH Server. |
Consumer Only Options 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Name | Default Value | Description |
---|---|---|
initialDelay
|
1000
|
Milliseconds before polling the SSH server starts. |
delay
|
500
|
Milliseconds before the next poll of the SSH Server. |
useFixedDelay
|
true
|
Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.
|
pollCommand
|
null
|
Command to send to SSH Server during each poll cycle. You may need to end your command with a newline, and that must be URL encoded %0A .
|
Usage as a Producer endpoint 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
When the SSH Component is used as a Producer (
.to("ssh://...")
), it will send the message body as the command to execute on the remote SSH server.
Here is an example of this within the XML DSL. Note that the command has an XML encoded newline (
&10;
).
Authentication 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The SSH Component can authenticate against the remote SSH server using one of two mechanisms: Public Key certificate or username/password. Configuring how the SSH Component does authentication is based on how and which options are set.
- First, it will look to see if the
certResource
option has been set, and if so, use it to locate the referenced Public Key certificate and use that for authentication. - If
certResource
is not set, it will look to see if akeyPairProvider
has been set, and if so, it will use that to for certificate based authentication. - If neither
certResource
norkeyPairProvider
are set, it will use theusername
andpassword
options for authentication.
The following route fragment shows an SSH polling consumer using a certificate from the classpath.
In the XML DSL,
<route> <from uri="ssh://scott@localhost:8101?certResource=classpath:test_rsa&seFixedDelay=true&elay=5000&ollCommand=features:list%0A"/> <log message="${body}"/> </route>
<route>
<from uri="ssh://scott@localhost:8101?certResource=classpath:test_rsa&seFixedDelay=true&elay=5000&ollCommand=features:list%0A"/>
<log message="${body}"/>
</route>
In the Java DSL,
from("ssh://scott@localhost:8101?certResource=classpath:test_rsa&useFixedDelay=true&delay=5000&pollCommand=features:list%0A") .log("${body}");
from("ssh://scott@localhost:8101?certResource=classpath:test_rsa&useFixedDelay=true&delay=5000&pollCommand=features:list%0A")
.log("${body}");
An example of using Public Key authentication is provided in
examples/camel-example-ssh-security
.
Certificate Dependencies 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
You will need to add some additional runtime dependencies if you use certificate based authentication. The dependency versions shown are as of Camel 2.11, you may need to use later versions depending what version of Camel you are using.
Example 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
See the
examples/camel-example-ssh
and examples/camel-example-ssh-security
in the Camel distribution.