弹簧集成:SFTP 入站通道适配器 主机'x.x.x.x'的真实性无法确定



我尝试使用以下代码下载文件:

<int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
    auto-startup="true" channel="receiveChannel" session-factory="sftpSessionFactory"
    local-directory="file:${directory.files.local}" remote-directory="${directory.files.remote}"
    auto-create-local-directory="true" delete-remote-files="true"
    filename-pattern="*.txt">
    <int:poller fixed-delay="${sftp.interval.request}"
max-messages-per-poll="-1" error-channel="sftp.in.error.channel" />
</int-sftp:inbound-channel-adapter>
<bean id="defaultSftpSessionFactory"
    class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <property name="host" value="${sftp.host}" />
    <property name="port" value="${sftp.port}" />
    <property name="user" value="${user}" />
    <property name="password" value="${password}" />
    <property name="allowUnknownKeys" value="true" />
</bean>

我确定用户已获得授权,因为我尝试过使用 shell:sftp user@x.x.x.x然后我写下密码,下载成功并带有"get"。

但是我无法下载文件,错误是:

调试日志:

        jsch:52 - Authentications that can continue: gssapi-with-mic,publickey,keyboard-interactive,password
2016-02-02 07:54:04 INFO  jsch:52 - Next authentication method: gssapi-with-mic
2016-02-02 07:54:04 INFO  jsch:52 - Authentications that can continue: publickey,keyboard-interactive,password
2016-02-02 07:54:04 INFO  jsch:52 - Next authentication method: publickey
2016-02-02 07:54:04 INFO  jsch:52 - Authentications that can continue: password
2016-02-02 07:54:04 INFO  jsch:52 - Next authentication method: password
2016-02-02 07:54:04 INFO  jsch:52 - Authentication succeeded (password).
2016-02-02 07:54:05 DEBUG SimplePool:190 - Obtained new org.springframework.integration.sftp.session.SftpSession@39c9c99a.
2016-02-02 07:54:05 DEBUG CachingSessionFactory:187 - Releasing Session org.springframework.integration.sftp.session.SftpSession@39c9c99a back to the pool.
2016-02-02 07:54:05 INFO  jsch:52 - Disconnecting from x.x.x.x port 22

我会为 jsch 和 org.springframework.integration 启用调试日志记录。

最后一条消息来自此代码...

@Override
public boolean promptYesNo(String message) {
    logger.info(message);  // <<<<<<<<< INFO message in your log line 538
    if (hasDelegate()) {
        return getDelegate().promptYesNo(message);
    }
    else {
        if (logger.isDebugEnabled()) {
            logger.debug("No UserInfo provided - " + message + ", returning:"
                    + DefaultSftpSessionFactory.this.allowUnknownKeys);
        }
        return DefaultSftpSessionFactory.this.allowUnknownKeys;
    }
}

由于您尚未提供委托UserInfo(根据您在问题中的配置),因此它应返回 true(因为您已allowUnknownKeys设置为 true )。

如果您无法弄清楚;请使用日志的相应部分编辑您的问题。

编辑

您删除了第一次编辑时发布的日志中最有用的部分:

2016-02-01 18:28:27 DEBUG DefaultSftpSessionFactory:544 - No UserInfo provided - The authenticity of host '192.168.21.36' can't be established.
RSA key fingerprint is 98:1d:7e:73:77:97:f6:af:f9:2a:fc:2b:21:8e:8e:bf.
Are you sure you want to continue connecting?, returning:false

"Returning:false"表示allowUnknownKeys属性是false,而不是您在配置中显示的true。也许您有另一个会话工厂 bean 覆盖了这个会话工厂 bean?

最新更新