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?

2
  • 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, 2011 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. Dec 8, 2011 at 0:09

3 Answers 3

2

Have you tried using something like ftp://user:[email protected] as the address ?

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

This example uses sftp but ftp should be similar.

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
1
  • Note that I asked about passing it in, whereas you're embedding it in the script. Jan 25, 2013 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .