Search code examples
spring-cloud-streamspring-integration-sftp

When using Key Based Spring Cloud Stream SFTP Source Private Key Property not Found


I've created an SFTP Source (sftp-source-kafka:2.1.0.M2) using the following definition on a local SCDF server dashboard:

sftp --local-dir=/tmp/inbox --filename-pattern=*.csv --task-launcher-output=true --remote-dir=/home/user/csv --private-key=file:/path/to/key/key-file.pem --username=user --host=***** --known-hosts-expression='"/path/to/hostfile/known_hosts"' | log

The known_hosts file and key files are both on the SCDF server and accessibe. When I launch the stream I get the following error:

Caused by: java.lang.IllegalArgumentException: either a password or a private key is required
    at org.springframework.util.Assert.isTrue(Assert.java:118)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:352)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:57)
    at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:438)

The stream works fine if I try it against a password based SFTP server. Am I specifying the key resource wrong? I've tried just the path without the "file:" in front and that causes the same error.


Solution

  • It's a bug in the source app; I don't see the private key property being read while configuring the session factory.

    Please open a GitHub Issue.