Password encryption needed for FTP script file transfer

55 views Asked by At

I have a WinSCP script which copies file over FTP protocol. But here my password is visible. Is there any option to make this password encrypted so that if anyone open the script couldn't see the actual one?

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\path\log\WinSCP.log" /ini=nul ^
  /command ^
    "open ftpes://username:[email protected]/" ^
    "cd /" ^
    "lcd ""C:\path\Source_datafiles""" ^
    "get ALMR*" ^
    "cd /" ^
    "rename /ALMR* /archive/ALMR*" ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

c:
cd "C:\path\Target_datafiles"
ren *.txt *.kis.txt

exit /b %WINSCP_RESULT%

enter image description here

1

There are 1 answers

0
Martin Prikryl On

How would you imagine encrypting the password in a way that the script can read it but no one else can? It is not possible. If the script can read it, anyone can (or at least anyone who has the same privileges as the local account that runs the script).

Though, you can make it harder to read the password. You can for example store it to a separate file and encrypt the file using Windows file encryption and make the file be accessible only the local account that runs the script.

See also WinSCP article Protecting credentials used for automation.