NAZEHA
NAZEHA

Reputation: 455

spring integration: sftp inbound-channel-adapter The authenticity of host 'x.x.x.x' can't be established

I tried to download files using the following code:

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

I'm sure that the user is authorized because i tried it with shell: sftp [email protected] then i write the password and the download succeed with "get".

but i can't download files, the error is:

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

Upvotes: 1

Views: 2752

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

I would enable DEBUG logging for jsch as well as org.springframework.integration.

That last message is coming from this code...

@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;
    }
}

Since you have not provided a delegate UserInfo (according to your configuration in the question), it should return true (because you have allowUnknownKeys set to true).

If you can't figure it out; edit your question with the appropriate part of the log.

EDIT

You removed the most useful part of the log you posted on your first edit:

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" means that the allowUnknownKeys property is false, not true as you show in your configuration. Perhaps you have another session factory bean that's overriding this one?

Upvotes: 1

Related Questions