spring integration:sftp inbound-channel-adapter无法建立主机'x.x.x.x'的真实性

时间:2016-02-01 16:02:44

标签: spring-integration sftp

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

<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”。

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

DEBUG LOG:

        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

1 个答案:

答案 0 :(得分:0)

我会enable DEBUG logging for 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

&#34;返回:假&#34;表示您的配置中显示的allowUnknownKeys属性为false,而非true。也许你有另一个会话工厂bean来覆盖这个?