WinSCP is a free SFTP tool for Windows that allow you to perform secured file transfer using SFTP, SCP or SSH-1/SSH-2 protocols. This article will show you how to create a Windows Job in OpCon to control a file transfer operated by WinSCP using FTPS or SFTP.
Requirements
- An MSLSAM
- WinSCP installed
Preparation
Depending on the user log in, a batch profile for WinSCP may need to be created. Create a Batch User within Enterprise Manager to match the user profile using WinSCP.
Then in the next step we'll create three global properties:
- Global Property for username: WinSCPUser
- Create Global property for password (Encrypted): WinSCPPassword
- Hostkey for public key : WinSCPHostKey (if setup is for FTPS, skip to the next step "Job Creation with FTPS protocol")
- Configuration of the SFTP Hotkey : see "Get SFTP Hostkey"
Job Creation with FTPS protocol
To upload a file, create a job with the following command line as example using "put":
"C:\Program Files (x86)\WinSCP\winscp.com" /log="C:\Winscp\Log\WinSCP\L$JOBID]].log" /command "open ftps://peWinSCPUser]]: SCWinSCPPassword]]@files.smatechnologies.com/" "**put** C:\Winscp\Debug.log /SMA_Employees/Jesparza/" "exit"
About the command line
"C:\Program Files (x86)\WinSCP\winscp.com"
: the folder where is located the winscp.com program/log="C:\Winscp\Log\WinSCP\L$JOBID]].log"
: the place where the log are sent/command "open ftps://peWinSCPUser]]:nSWinSCPPassword]]@files.smatechnologies.com/"
: the connection string to the server- "put
C:\Winscp\Debug.log /SMA_Employees/Jesparza/"
: the source file you want to upload and its destination (get for download)
- When using this command, ensure /log has a path to a directory, this will begin saving log files to the directory, this will help with troubleshooting.
NOTE
If the directory has a space use 2 double quotes from the start of the directory to the end of the file extension.
EXAMPLE
“put“ ”C:\Program Files\File.txt”” /Directory/”
To download a file, create a job with the following command line as example using "get":
"C:\Program Files (x86)\WinSCP\winscp.com" /log="C:\Winscp\Log\WinSCPsc$JOBID]].log" /command "open ftps://JOWinSCPUser]]:omWinSCPPassword]]@files.smatechnologies.com/" "get /SMA_Employees/Jesparza/File.txt C:\Winscp\ " "exit"
Get a public HostKey for SFTP
Open puttygen.exe which is located directly under PuTTY or WinSCP, examples:
C:\Program Files\PuTTY\puttygen.exe
C:\Program Files (x86)\WinSCP\PuTTY\puttygen.exe
Copy the Public key generated into the WinSCPHostKey global property created in the Preparation step.
To download a file using SFTP, create a job with the following command line as example using "get" with a -hostkey parameter: "C:\Program Files (x86)\WinSCP\winscp.com" /log=”C:\Winscp\Log\WinSCPWi$JOBID]].log” /command "open sftp://ogWinSCPUser]]:IDWinSCPPassword]]@files.smatechnologies.com/ -hostkey=""PaWinSCPHostKey]]" "get /SMA_Employees/Jesparza/*.log C:\Winscp\" "exit"
- When using this command, ensure /log has a path to a directory, this will begin saving log files in the directory, this will help with troubleshooting.
NOTE
If the directory has a space use 2 double quotes from the start of the directory to the end of the file extension.
EXAMPLE
“put“”C:\Program Files\File.txt”” /Directory/”
EXAMPLE DOWNLOADING (FILES) USING PRIVATE KEY AND PASSPHRASE
winscp.com /log="C:\Winscp\Log\WinSCP.log" /command "open sftp://username@sftp.SMA.com/ -privatekey=""C:\Location\FileName.ppk"" -passphrase=""PASSPHRASE""" "get /Dir/Filename.txt D:\directory\" "exit"