How to transfer file with SFTP using OpenSSH in SSIS?

Viewed 582

In my project I have to use OpenSSH sftp tool to transfer file using SFTP and it should be executed from SSIS. I searched a lot from last one month but not able to find any solution. I did transfer file using WinSCP from SSIS, but client is now switching to OpenSSH.

Anyone have any idea about transferring file using OpenSSH? It will be a great help if anyone have any solution.

I am transferring single files and I want both upload and download. We are using a private key to authenticate.

In WinSCP I was executing a .bat file which will call a .txt file and that .txt have the SFTP put and get commands.

1 Answers

So I assume you have a batch file that runs WinSCP like this:

c:\path\to\winscp.com /script=c:\path\to\script.txt

And a WinSCP script script.txt that authenticates to an SFTP server using a private key and uploads and downloads a file:

open -privatekey=c:\path\to\key.ppk sftp://username@example.com/
get /remote/path/file.txt c:\local\path\file.txt
put c:\other\local\path\file2.txt /other/remote/path/file2.txt
exit

That would translate to OpenSSH sftp like this:

sftp.exe -b c:\path\to\script.txt -i c:\path\to\key.pem username@example.com

And a sftp script script.txt that transfers the files:

get /remote/path/file.txt c:\local\path\file.txt
put c:\other\local\path\file2.txt /other/remote/path/file2.txt

You have to use PuTTYgen to convert your WinSCP .ppk private key to PEM format to use it with OpenSSH.


There's a guide for converting OpenSSH script to WinSCP. While that's the exact opposite of what you want, with some effort, you can still dig some ideas from it.

Related