If you need to automatically download a file from a SFTP site, perhaps a regular news or traffic MP3, cURL may be the tool for you! These instructions explain the right versions of the software to download on Windows, and the correct commands to run.
Let’s assume you have a fairly recent Windows x64 version (Windows 7, Server 2008 R2, etc.)
There are two packages you need to download:
- cURL with SSH2, SSL and SSPI
These two tools can be used together to connect to SFTP sites and download specific files.
Step 1: Downloading cURL (with SSH2, SSL and SSPI) for Windows
cURL builds for Windows are distributed by paehl.com. On the downloads page, select the fourth version in the main list (“Download SSH2, SSL, SSPI version”).
Step 2: Downloading OpenSSL for Windows
OpenSSL for Windows builds are distributed by fulgan.com. On the download page, select the latest i386-win32 version. At the time of writing, this file was called “openssl-1.0.2h-i386-win32.zip”.
Step 3: Extracting the files
We need to get two files from each ZIP archive and put them into the one directory.
From the cURL download, find:
From the OpenSSL package:
Create an empty directory on your local disk, and copy these four files into it.
Step 4: Install Visual C++ Redistributable (Optional)
You may need to install the Visual C++ Redistributable. If so, this can be downloaded directly from Microsoft.
Step 5: Running the Command
The command itself is fairly straightforward. The following example assumes you want to download a file called “NEWS_FULL.mp3” and save it as “news_output_full.mp3”:
curl.exe -u myusername:mypassword -k -o c:\filedownload\news_output_full.mp3 sftp://myserver.mediarealm.com.au/home/myusername/NEWS_FULL.mp3
Here’s an explanation of the command line options:
- -u myusername:mypassword
Specify the credentials you need to login to the SFTP server. If the credentials contain special characters, wrap the whole thing in double-quotation marks.
This option is optional, but will allow you to connect to untrusted servers (self-signed certificates count as untrusted)
- -o c:\filedownload\news_output_full.mp3
Specify the full output filename
The last parameter is the source filename, with the full protocol, server, path and filename listed.
Automating this Command
To automatically run this command, save the full command as a BAT file and schedule it from the Windows Task Scheduler.
Get the Broadcast Technology Newsletter
Sign up for the email newsletter about media and technology. Sent irregularly. No spam.