Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


[Solved] WinSCP .bat file to upload SFTP with ssh passphrase hostkey etc

You guys, I have no programming experience but after SCOURING a ton of posts I finally have it figured out. I was having a hard time because so many of the other posts had it written for .net or C# and most were using an abundance of "s which apparently in the.bat file you don't need (I mean you do, just not for the OPEN command)

Anyway, if you're just making a simple .bat file to upload files to the SFTP site every day, here is how to do it:

**** Here is what's in the .Bat file **** (keep the quotes and EVERYTHING how I have it)

"C:\Program Files (x86)\WinSCP\winscp.exe" /console /script="C:\Program Files (x86)\Script\WINSCP_Upload.txt"
move "C:\Program Files (x86)\Path_to_Text File\*.txt" "C:\Program Files (x86)\Path\FTPDone\"

****** Here is what's in the WINSCP_Upload.txt File ***** (Port is only needed if it's NOT 22)
and if you need it to go to a subfolder, it should be like @SITE:PORT/Subfolder then 1 space

option batch on
option confirm off
open sftp://username:Password@SITE:PORT -hostkey="rsa-key-2018blah" -privatekey="C:\Users\user\PATH\SSH Key.ppk" -passphrase="MyPassPhrase"
option transfer binary
put "C:\Program Files (x86)\Path_to_Text File\*.txt"