2

I'm scripting WinSCP, and need to dynamically pass in a FTP username and password, depending on which environment I'm using.

However, the docs say, "WinSCP does not support providing the passphase from command line or by other means allowing automation"

Is there another way?

  • One thing to be aware of (if you weren't already) is that the username and password will be stored in plain text. If there's a console log (or something like doskey is running), it may be possible for someone to retrieve these passwords. – Andrew M. Dec 7 '11 at 23:10
  • @Redmumba, correct. The password would be exposed to a local attacker, or local malicious code with sufficient privileges. However, there are mitigating factors in our case to prevent escalation. Further, FTP passwords are already vulnerable to network interception. – Matthew Flaschen Dec 8 '11 at 0:09
2

Have you tried using something like ftp://user:pass@ftp.example.com as the address ?

You script can then build this uri depending on you environment.

This example uses sftp but ftp should be similar.

| improve this answer | |
2

The following is what worked for me

created a file called script.text. Following is the content of script.txt

open ftp://uname:pwd@ftpserver_url

then from the command prompt executed the following statement

c:\ "path_to_winscp\WinSCP.exe" /console /script=c:/script.txt
| improve this answer | |
  • Note that I asked about passing it in, whereas you're embedding it in the script. – Matthew Flaschen Jan 25 '13 at 5:40
1

Use /parameter and %1% and %2% in the script:

WinSCP.com /console /parameter username password /script=some.script

In some.script:

open ftp://%1%:%2%@servername
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.