sftp:outbound-channel-adapter 拒绝 HostKey

Sar*_*thy 3 sftp spring-integration

我正在尝试使用 Spring Integration sftp 出站通道适配器将文件发送到 sftp。

<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter" session-factory="sftpSessionFactory"channel="sftpChannel" charset="UTF-8" remote-directory="/sftp/home/sftp_foler"  remote-filename-generator-expression="'dummy.txt'"/> 
Run Code Online (Sandbox Code Playgroud)

我收到以下错误..

Caused by: java.lang.IllegalStateException: failed to connect
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:272)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:377)
    ... 42 more
Caused by: com.jcraft.jsch.JSchException: reject HostKey: myHost
    at com.jcraft.jsch.Session.checkHost(Session.java:791)
    at com.jcraft.jsch.Session.connect(Session.java:342)
    at com.jcraft.jsch.Session.connect(Session.java:183)
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:263)
Run Code Online (Sandbox Code Playgroud)

我想,我可能必须将 StrictHostKeyChecking 设置为 no,但是如何在 sftp 出站网关中设置该值?请提供您宝贵的建议。

Art*_*lan 6

也许这个:

以前,DefaultSftpSessionFactory无条件允许连接到未知主机。这现在是可配置的(默认为 false)。

工厂现在需要一个配置knownHosts文件,除非allowUnknownKeys属性是true(default false)。

http://docs.spring.io/spring-integration/reference/html/whats-new.html#_default_sftp_session_factory