Automated WinSCP file transfers

This is the line I put in a Scheduled Task to download a remote directory and save it locally. You should be able to use it in reverse to upload something.

"C:Program FilesWinSCPWinSCP.exe" /console /log=winscp.log /command "option batch on" "option confirm off" "open USERNAME:PASSWORD@EXAMPLE.com -hostkey=""ssh-rsa 2048 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF"" " "get /home/backups/* c:backups*" "exit"

Separated for readability:

"C:Program FilesWinSCPWinSCP.exe"
/console
/log=winscp.log
/command "option batch on" "option confirm off"
"open USERNAME:PASSWORD@EXAMPLE.com -hostkey=""ssh-rsa 2048 00:11:...:EE:FF"" "
"get /home/backups/* c:backups*"
"exit"

Note that you must replace USERNAME, PASSWORD, EXAMPLE.com, and the host key of 00:11…EE:FF with real values.

You can get the host key by ssh-ing into EXAMPLE.com and noting the key fingerprint displayed the first time you’ve connected to it.
If you’ve already connected, it’s likely stored in *nix under ~/.ssh/known_hosts (delete its line to force it to show you the fingerprint upon next connect) or for Windows/PuTTY in the registry at HKEY_CURRENT_USERSoftwareSimonTathamPuTTYSshHostKeys

Advertisements

One thought on “Automated WinSCP file transfers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s