LSU Health New Orleans

Job Opportunities | Contact | Donate

Thursday, April 24, 2014   2:23 AM    |   70°F

Secure FTP Client Setup for Windows


This page contains all the  downloads and installation instructions that are needed to access our secure FTP services from a Microsoft Windows System. Unix users should contact for assistance.

For normal SFTP services, users will only need to download the "sftp2.exe" client, but for more advanced users that plan to use scripts and scheduled tasks to access the SFTP services, there is an additional download and further instructions following the sftp2 client instructions.

Download SFTP2 Client

To access the secure ftp server, all uses must first download this free SSH Secure FTP client:  sftp2.exe (1 Mb)

How to Download the SFTP Client

  1. Download "sftp2.exe"
  2. A warning message will appear when downloading, but save anyway.  It is recommended to save this file in you "C:\windows" directory by traversing the path in the window. If you are not logged into the system that the SFTP services will be used from, you should then copy this file to that system's c:\windows directory.

    NOTE: After the file has been saved, another window may appear asking you to "Open" the file, do NOT choose to open the file. This file is not a zip file and doesn't need to be opened. Simply click "Close".
  3. Once the file is saved, you can test accessing the secure ftp server.
  4. Open a command prompt on the system that you saved the file.
    (To open a command prompt: click on "Start", "Run" and enter "cmd").
  5. At the command prompt, you will need to type in the client "sftp2", the LSUHSC NT ID that you were assigned and the domain name as per the example below:
  6. Note the space between sftp2 and the username.
    If you have entered the command correctly, you will see a message that this is your first time accessing the secure FTP server and would you like to save the host key to your local system. By entering "yes" to save this key, will prevent displaying this message in the future. Note: you must enter "yes", not just "y".
    Next,  you will be prompted for the password of the special account assigned to you.
    If you enter the correct password, the sftp prompt will display:s
  7. You have successfully accessed SFTP, and can enter "quit" to exit.

Accessing SFTP via Scripts (For Advanced Users)

When automating SFTP transfers, the SFTP client should first be downloaded as per the instructions above.

To automate the SFTP session using scripts, an authentication method to communicate with the SFTP server is needed. We have decided to use "Expect for Windows" to provide this method. Expect (1.5 MB) is a freeware program that was created by Gordon Chaffe ( Expect must be downloaded and installed on the system that the script will run on.

How to Download and Install "Expect for Windows".

  1. Since the scripts that we create use the "Sftp2" client above, please follow the instructions above and install sftp2 first.
  2. Click on "Expect.exe" download link here
    1. A window will appear asking to save the file, click on "Save". Since Expect will be installed, you should save it in a temporary directory such as, c:\temp or c:\windows\temp.
    2. After the file has been saved, another window will appear asking you to "Open" the file. Click open to start the install of Expect.
    3. The Expect install will default to the C:\Program Files\Expect directory. We recommend to accept all the defaults during the install by clicking "Next" at each prompt. When the install is complete, click "Close". (The Expect program installs two other small programs, "TCL80" and "Wish80",  that are used to test scripts.)
  3. Now that Expect has been successfully installed, we need to map the "tcl" file extension to use the "Wish80" program installed by Except.
    1. Open your Windows Explorer by "Right" clicking on "Start" and then choosing "Explore".
    2. In the left-side pane, traverse to the directory path, "c:\program files\expect-5.21". Note: If you installed Expect to a different location, traverse to that location.
    3. The right-side pane should now be displaying the Expect directories: "bin", "include", and "lib". If so, right click your mouse in the right-side pane and a menu will appear. Chose "New" then "Text Document".
    4. Name the new document "test.tcl". You may be prompted that changing the file name may no longer allow it to work, click "Yes" or "OK".
    5. Next, hold down the shift key and right click on the new document file "test.tcl". A menu you will display, choose "Open With", and then "Choose Program".
    6. The Open With Window will appear, click the "Other" button at the bottom of the window and traverse to the Expect Bin Directory: "C:\program files\expect\bin".
    7. In the Expect\Bin directory choose the program "Wish80.exe" and then "OK" to accept.
    8. To test the "tcl" mapping, double click on the "test.tcl" that you created. If your mapping was successful, a small window will appear with the name Test.  If the window appears, the mapping was successful, simply click the "X" to close it.  If the window does not appear, contact for assistance.

How to Setup the Script File to Automate SFTP

Before working with script files, you should already:

  • Installed the sftp2 client
  • Tested accessing the SFTP server manually
  • Accepted the SFTP server host key
  • Installed the Expect program, and
  • Mapped the "tcl" extension  to the "Wish80.exe" program

First we will describe a small overview of why and how the script file works, then give an example script file, and finally give other commands that can be added to the script.

Script files are used to automatically access the Secure FTP services (SFTP). Because the SFTP services require a user id and password to login, there must be a method in place that will pass the user id and password when prompted by the SFTP. Since the sftp2 client doesn't provide a method to pass this information, we will use the "Expect / Wish80" programs to provide this process.

  1. First, start by creating a script file (a text file) using Notepad, you will need this file with the ".tcl" extension. Actually, you can open the "test.tcl" that you created in the steps above.
  2. The first line of the script file will start the connection to the SFTP server:
    spawn sftp2
  3. The next line will use an Expect statement to tell the script how the server is going to reply :
    expect -exact "UserID's password: "
  4. After the script has received this reply, it will then send the UserID's password:
    send "PASSWORDHERE\r"
    You must include the "\r" which sends a return key.
  5. At this point you are logged into the SFTP server. In your script, you can use normal ftp commands to change directories, get / put files, etc... Just use the "send" and "\r" around the commands:
    To change a directory:  send "cd /directorypath\r"
    To upload a file: send "put filename.extension\r"
  6. VERY IMPORTANT: The script file can contain many commands, but must end with these three statements:
    send "quit\r"
    Expect eof
    spawn kill wish80.exe
    (This command kills the process that the script is running under. Because the Expect and Wish80 applications were converted from Unix modules, the script process will continue to run even after your commands have been completed, and each time you run the script, a new process will be created.)
  7. Example script file: The User ID is "John, the password is "12345", the SFTP server IP is 123.456.789.10 and we want to upload the file "tool.dat" to the directory "support":
    spawn sftp2
    expect -exact "John's password: "
    send "12345\r"
    send "cd /Support\r"
    send "put tool.dat\r"
    send "quit\r"
    expect eof

More FTP2 Commands / Options

How to Setup a Schedule Task That Will Run the Script

One additional phase can be setup to help automate the SFTP process. Specific times can be scheduled when the script should run, (hourly, daily, weekly, bi-weekly, etc.)

  1. Open the Microsoft Scheduled Tasks by clicking "Start", "All Programs", "Administrative Tools", "Task Scheduler"
  2. Start the Scheduled Task Wizard by double clicking on "Add Schedule Task".
  3. After the Wizard starts, click on "Next" to confirm that you want to begin..
  4. The wizard will take about minute to start and then display a list of available programs on your system.
  5. Click on the "Browse" button located on the bottom of the window and traverse to your script file. If we use the "test.tcl" from the example above, this file would be located at "C:\program files\expect\test.tcl".
  6. Next, you will be prompted for a name for the task and when the task should run. By clicking next, you will be allowed to enter specific time and start date of process. All these options can be changed at a later dated if needed.
  7. By clicking next, you will be prompted to enter the User ID that the task needs to run as. You should NOT use your User ID, because once your password expires, you will need to change it here every month. If not, the task will fail and your account will eventually get locked out. You should use the system account issued to you by Information Security. Also, this account will need to be added to the proper local system account that is allowed to run scheduled tasks. Contact your local computer supporter for assistance with this.
  8. Click Finished. You can now test your schedule task by right-clicking on the Schedule Task and choosing "Run".