Automating SFTP Transfers

Instructor: Louay Chebib
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.

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.

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account