• At a guess, I would say that WinSCP is prompting for a password it never receives.

    How are you logging into your target SFTP server? Are you using its in-built stored sessions to store a password (or private key)?

    If so, the sessions are stored in a user-specific registry key (HKEY_CURRENT_USER\Software\Martin Prikryl\WinSCP 2\Sessions). This will not be the same for your user as for the user running your SQL Server Agent.

    Two options I can think of (if this is indeed the issue):

    1. Define a proxy account for the user that stored the session in WinSCP, and run the WinSCP step/job under that proxy account

    2. Export the WinSCP user-specific registry keys and import them into the user hive for the user running your SQL Server Agent

    For example, if your SQL Server Agent is running as NETWORK SERVICE:

    1. Open REGEDIT

    2. Navigate to the "HKEY_CURRENT_USER\Software\Martin Prikryl" key

    3. Right-click the "WinSCP 2" key and choose Export - specify a filename

    4. Open that file with a good text editor

    5. Replace all instances on "HKEY_CURRENT_USER" with "HKEY_USERS\S-1-5-20" and save

    6. In REGEDIT, go to File >> Import, and select your edited .reg file

    Now NETWORK SERVICE should have the same saved sessions as your own user account.

    (I should point out that manual fudging of the Registry, without knowing what you are doing and without a really good, thoroughly tested backup is a really bad idea -- make sure you test this on a non-essential test server, and have a good backup of your production first)

    HTH

    J.