【问题标题】:SSH Configuration with WebSphere and Spring Integration使用 WebSphere 和 Spring 集成的 SSH 配置
【发布时间】:2012-12-10 23:43:05
【问题描述】:

我有一个托管在 WebSphere 上的 Web 应用程序 (Spring MDP),它使用 SFTP 在 3 个不同的服务器(Unix 机器)上侦听消息并生成一些文本文件。我们正在使用 Spring 集成 (DefaultSftpSessionFactory) 来建立 SFTP 连接,并使用目标主机的用户凭据(用户名/密码)将文件写入不同的服务器。

现在,根据新要求,我们必须停止使用用户名/密码来连接服务器,而是使用 SSH 密钥对。我们得到了指示,我们必须使用 SSH 密钥为“wasadm”用户建立连接。这是我到目前为止所做的:

  1. 从 WAS 管理员团队获取了“wasadm”用户的公钥。
  2. 已将公钥安装到不同服务器的授权密钥。

现在,我的问题是 - 如何配置我的应用程序,以便它获取“wasadm”SSH 私钥以连接到目标框。 (私钥位于“/home/wasadmin/.ssh”位置。EAR 应用程序是否可以访问此目录?如果可以,如何配置 DefaultSftpSessionFactory 以使用此私钥进行身份验证)。

非常感谢任何指针和指导。

非常感谢。

-阿什

【问题讨论】:

  • 您应该能够在相应的 java 对象中加载受信任/密钥存储或证书文件,例如 TrustedStore 或 X509Certificate 或类似的东西。基本上没有什么可以阻止您执行新文件(某个位置).. 没有什么可以期待 WAS_INSTALL\java\jre\lib\security 下的 java.policy 文件,它会(在默认设置下)阻止您访问默认安装的文件。 .

标签: java spring jakarta-ee websphere spring-integration


【解决方案1】:

sftp 示例展示了如何做到这一点...https://github.com/garyrussell/spring-integration-samples/tree/master/basic/sftp

您在会话工厂上配置它...

<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <property name="host" value="${host}"/>
    <property name="privateKey" value="classpath:path-to-key/sftp_rsa"/>
    <property name="privateKeyPassphrase" value="${passphrase}"/>
    <property name="port" value="22"/>
    <property name="user" value="${user}"/>
</bean>

<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
            session-factory="sftpSessionFactory"
...

【讨论】:

    猜你喜欢
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多