132.8. 身份验证
SSH 组件可以使用以下两种机制之一对远程 SSH 服务器进行身份验证:
- 公钥证书
- 用户名/密码
根据如何设置选项,配置 SSH 组件如何进行身份验证。
-
首先,它会查看
certResource选项是否已设置,如果设置了,则使用它来查找引用的公钥证书并使用该证书进行身份验证。 -
如果没有设置
certResource,它将查看是否设置了keyPairProvider,如果设置了 keyPairProvider,它将将其用于基于证书的身份验证。 -
如果没有设置
certResource或keyPairProvider,它将使用选项进行身份验证。尽管用户名和密码是在通过用户名和密码SshConstants.USERNAME_HEADER(CamelSshUsername)和SshConstants.PASSWORD_HEADER(CamelSshPassword)设置的端点配置和标头设置的标头中提供的,也会使用标头中设置的凭证。
以下路由片段演示了使用 classpath 中的证书进行 SSH 轮询消费者。
XML DSL
<route>
<from uri="ssh://scott@localhost:8101?certResource=classpath:test_rsa&useFixedDelay=true&delay=5000&pollCommand=features:list%0A"/>
<log message="${body}"/>
</route>
<route>
<from uri="ssh://scott@localhost:8101?certResource=classpath:test_rsa&useFixedDelay=true&delay=5000&pollCommand=features:list%0A"/>
<log message="${body}"/>
</route>
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}");
例如,example /camel-example-ssh-security 中提供了使用公钥身份验证的示例。