Post a reply

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

Options

Topic review

martin

gcefaloni wrote:

If I wanted to use the same script to connect to a SFTP that uses a privatekey with a password. What should I modify so that the password of the privatekey is automatically entered?

Use -privatekey and -passphrase switches with the open command:
https://winscp.net/eng/docs/scriptcommand_open
gcefaloni

If I wanted to use the same script to connect to a SFTP that uses a privatekey with a password. What should I modify so that the password of the privatekey is automatically entered?
martin

Indeed, that's better.
gcefaloni

Changed it to :

open sftp://ftpNymbus:***@ftp.**.ca/ -hostkey="ssh-rsa 2048 AAiK4+*/XTrC/w3ik7IKHs=" -rawsettings ProxyPort=0

put -latest -nopreservetime "C:\Users\Gab\Dropbox\Nymbus Bonds\Portfolio\Position Files\*.csv" "/To_Folder/"

close

exit


I think it might work better that way?
Guest

Re: Scheduled uploads with & without RSA key using task scheduler

Log file is attached
martin

Re: Scheduled uploads with & without RSA key using task scheduler

Well, you enable logging to a file:
/log="C:\Users\Gab\Dropbox\Nymbus Bonds\Portfolio\Logs\position_file.log"
So please post that file.
gcefaloni

Re: Scheduled uploads with & without RSA key using task scheduler

martin wrote:

Show us the log please.


The log for task scheduler? How would I go about doing that?
martin

Re: Scheduled uploads with & without RSA key using task scheduler

Show us the log please.
gcefaloni

Scheduled uploads with & without RSA key using task scheduler

Hi,

I'm trying to schedule an upload of the latest .csv file that has been created to 2 sftp remote servers, one that using RSA private key and the other that doesn't, using the task scheduler but it doesn't seem to work for me. I was wondering if you guys could help me out.


For server that DOESN'T use Private RSA Key:
Script.txt
# I copied that from Generate Script Code within WinSCP
open sftp://ftpuser:password@ftp.example.ca/ -hostkey="ssh-rsa 2048 00-000-0-0-00-0=" -rawsettings ProxyPort=0 (the port for the server is 22, should I change that even if it was autogenerated script based on the working settings?)

lcd C:\Users\myuser\Dropbox\Portfolio\Position Files\
put *.csv /From_Me/ latest -nopreservetime

exit



Task Scheduler Action
Program/Script
"C:\Program Files (x86)\WinSCP\WinSCP.exe"

Arguments:
/log="C:\Users\Gab\Dropbox\Nymbus Bonds\Portfolio\Logs\position_file.log" /ini=nul /script="C:\Users\Gab\Dropbox\Nymbus Bonds\Portfolio\position_file_script.txt"

__________________________________________________________________________


For server that DOES use Private RSA Key:
Script.txt
# I copied that from Generate Script Code within WinSCP
open sftp://user@sftp.server2.com/ -hostkey="ssh-ed25519 256 00-000-000-000-000-000=" -privatekey="C:\Users\myuser\Dropbox\ssh-private-key.ppk" -rawsettings AgentFwd=1 GSSAPIFwdTGT=1 ProxyPort=1 (the port for the server is 22, should I change that even if it was autogenerated script based on the working settings?)

lcd C:\Users\myuser\Dropbox\Portfolio\Position Files\
put *.csv /From_Me/ latest -nopreservetime

exit


Task Scheduler Action
Program/Script
"C:\Program Files (x86)\WinSCP\WinSCP.exe"

Arguments:
/log="C:\Users\Gab\Dropbox\Nymbus Bonds\Portfolio\Logs\position_file.log" /ini=nul /script="C:\Users\Gab\Dropbox\Nymbus Bonds\Portfolio\position_file_script.txt"


Is there something I need to do differently in each scenario of with or without RSA private key for it work when I run the task scheduler? Right now it shows as task completed but nothing actually uploads to the remote servers. I've tried while keeping the application opened or keeping it closed. Either way, it doesn't work for the moment. Any suggestions for modifications?

Thank you!