cancel
Showing results for 
Search instead for 
Did you mean: 

Spring SFTP DefaultSftpSessionFactory to upload file with ppk key

0 Kudos
1,447

We are using the below spring configuration to download csv file to local folder and this is working fine. Is it also possible to upload a file using similar spring configuration using a .ppk file for authentication?

<bean id="rtsftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <property name="host" value="${rtHost}"/>
    <property name="password" value="${rtPassword}"/>
    <property name="port" value="${rtPort}"/>
    <property name="user" value="${rtUser}"/>
    <property name="allowUnknownKeys" value="true"/>
</bean>

<int:channel id="sftpChannel"/>

<!-- Copy remote file to local directory -->
<sftp:inbound-channel-adapter  id="rtsftpAdapterAutoCreate" session-factory="rtsftpSessionFactory" channel="sftpChannel" filename-regex="^(content.*).csv"
    remote-directory="${rtRemoteFolder}" local-directory="#{baseDirectory}" auto-create-local-directory="true" auto-startup="${sftp.on}"
    delete-remote-files="true">
     <int:poller cron="0 0 * * * *"/>
</sftp:inbound-channel-adapter>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Ansari,

You would first need to convert the ppk file to openSSH key first and then pass the privateKey along with the privateKeyPassPhrase to the rtsftpSessionFactory bean. like below:

<bean id="rtsftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <property name="host" value="${rtHost}"/>
    <property name="port" value="${rtPort}"/>
    <property name="privateKeyPassphrase" value="${passphrase}"/>
    <property name="privateKey" value="${path to private key}"/>
</bean> 

Here is the link which can be used for the conversion.

.ppk file to openssh key conversion

I hope this helps you.

thanks,

Himanshu Mehta

Answers (0)