Secure File Transfer Protocol (SFTP) is an excellent way to safely and securely copy files between computers over a secure connection. Automated file transfers are powerful ways to copy data files between computers without human intervention. The right tools make setting up this automation easy.

Automating SFTP Transfers

Ever wonder how to set up a way to automatically copy files from one computer to another? File Transfer Protocol (FTP) is the normal, most common way to copy files between computers. FTP is a protocol, or set of rules, that copies a file in pieces and makes sure the file arrives correctly at the other computer. FTP was developed in a simpler time when data security was not of great concern.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!

order now

Since computer files contain information, transferring files from one computer to another is an essential data processing task. Before high speed data networks, these files would be copied onto magnetic tapes and shipped by courier from location to another. A magnetic tape is considered to be portable media that can store or transport data. Data networks provide electronic connections between different computers and FTP is the tool used to copy files along these connections.

SFTP was developed as a secure way to use FTP. SFTP uses Secure Socket Shell (SSH) Protocol to create a secure connection where the FTP transfer can be run to copy a file over the SSH secured connection. SSH is used to secure many types of connections over the Internet, e.g., SSH is what keeps your password secure when you sign into your bank’s website.

Transferring files using SFTP requires both an SFTP Client and Server. SFTP client software allows users to logon to a remote SFTP server and send or receive files. Some examples of SFTP client software packages include: WinSCP, SWISH, BitKinex, and IPswitch.

Automated processes make it possible for computers to operate without human intervention. An automated SFTP process can be setup to send or get needed files as soon as they are available. This can happen without the operator taking any special action. This can be very useful when files arrive at any time of day or night and when there are many files to transfer.

Some SFTP Client software programs include the ability to create a script. An SFTP script is a set of instructions that tells the program what data file to transfer and how to transfer it. Using scripts, an operator can create the instructions needed for automated file transfer. The process of creating automated scripts requires planning, testing, and revision.

WinSCP is one of the most popular SFTP Client software programs that includes scripting. WinSCP is open source and is freely available to anyone.

WinSCP Scripting Commnads

Command Descrition
call Executes arbitrary remote command
cd Changes remote working directory
chmod Changes permissions of remote file
close Closes session
exit Closes all sessions and terminates the program
get Downloads file from remote directory to local directory
help Displays help
keepuptodate Continuously reflects changes in local directory on remote one
lcd Changes local working directory
lls Lists the contents of local directory
ln Creates remote symbolic link
lpwd Prints local working directory
ls Lists the contents of remote directory
mkdir Creates remote directory
mv Moves or renames remote file
open Connects to server
option Sets or shows value of script options
put Uploads file from local directory to remote directory
pwd Prints remote working directory
rm Removes remote file
rmdir Removes remote directory
session Lists connected sessions or selects active session
synchronize Synchronizes remote directory with local one
Use the help command inside WinSCP to get detailed help on any command. e.g. help option

For example: To transfer a file an SFTP script needs to:

  1. Establish a secure connection to a remote server using a login ID and password (OPEN)
  2. Upload a file using a PUT command
  3. Download a file using a GET command
  4. When the transfer is finished, use the EXIT command to close the connection.

Create a file ‘myscript.scr’ containing your commands:
option batch on
option transfer binary
open [email protected]??somesftpserver??.com
cd MyRemoteFolder
put ‘C:LocalSFTPOUTfoldersomefile.txt’

Notes on creating and using the above automation script:
*Use your User ID and Server Address in the open command place of [email protected]??somesftpserver??.com
*The option commands tell the program that you are running in ‘batch’ (automated without human intervention) and that the file transfer mode is ‘binary’ (the file is transferred ‘as is’ without any translation).
*For this script to work, you need to store your SFTP password inside WinSCP. Care needs to be taken when storing SFTP passwords inside the WinSCP application as this may not be allowed under the security rules in some environments.

Execute this script at the command line:
;;’C:…’ /script= myscript.scr

A developer may generate needed scripts programmatically and run these using a scheduler that runs programs for specific conditions such as specific times or the existence of certain files. Each of the SFTP client software packages has a different scripting language and syntax. Many command options exist and the users should explore what they need and test their scripts under a variety of conditions to make sure that they get the results they expect.

Lesson Summary

Transferring files from one computer to another is an essential data processing task. SFTP uses Secure Socket Shell (SSH) Protocol to create a secure connection where FTP transfers run. Automated processes make it possible for computers to operate without human intervention. An SFTP client software package is need to transfer files between computers. Some SFTP clients support a scripting language that allows users to setup automated SFTP transfers.