In this tutorial, we'll show you how to automatically forward FTP uploads to an SFTP server.
When would you need to transfer files from FTP to SFTP?
The ability to receive files via FTP and then forward them out via SFTP can be particularly useful if the "receiving" FTP server is behind your corporate firewall and you want to forward files to a remote SFTP server.
Transferring files over a secure file transfer protocol like SFTP, instead of just plain FTP, will allow you to thwart eavesdroppers who may be sniffing on the network. SFTP encrypts data while it's in transit. This kind of protection is needed especially in highly insecure networks like the Internet.
Recommended read: Countering Packet Sniffers Using Encrypted FTP
Let's now proceed with the steps for this tutorial.
1. Verify whether both your FTP and SFTP services are up
Make sure you have both the FTP service and the SFTP service running on your installation of JSCAPE MFT Server. If you have everything set up, it's really just a matter of going into the Services node, clicking Add, and then adding the required services. However, if you're just getting started, I would recommend you start by reading the following articles:
or you could read the documentation.
Here's how your Services panel should look like after you've added the two services.
2. Add a trigger that fires after an FTP upload
Now that you have both services up and running, the next step would be to add a trigger that would respond to each FTP upload. In this scenario, the upload can come from either an FTP client or another FTP server (which in this case would be acting as a client to this server).
Go to Triggers > Triggers tab, and then click Add.
When the next window appears, give the trigger a name (e.g. "Forward FTP upload to SFTP server"). After that, expand the Event type drop-down list and then select File Upload. Click the Next button to proceed.
3. Enter a trigger condition (or not)
You'll now be brought into the trigger conditions window. Here, you can specify certain conditions that would filter out uploads whose files you wouldn't want to forward to the SFTP server. So, for instance, you could specify the ServerPort that received the uploaded file. For FTP, that would usually be port 21.
Therefore, you could add the following expression into the trigger conditions box:
ServerPort = 21
You can find more Variables, Functions, Operators, etc, by clicking on the buttons at the bottom of that screen. For now, just leave it empty.
Once you're done, just click the Next button.
4. Add the SFTP File Upload trigger action
Now it's time to add the trigger action. A trigger action is the action you want the trigger to carry out in response to the file upload. In our case, we'd like the trigger to forward (upload) the recently uploaded file to a SFTP server. One action that's suitable for this purpose is the SFTP File Upload trigger action.
Click the Add button to start adding the trigger action.
Select the SFTP File Upload trigger action and then click OK.
5. Enter the SFTP File Upload trigger action parameters
Here, you would need to enter pertinent details such as the:
- Hostname - This is the hostname or IP address the SFTP service will be listening on
- Port number - The port number used by the SFTP service. Normally 22.
- Timeout value - The time (in seconds) before the session times out.
- Username - This is the username of the account on the SFTP server that will be used for logging in
- Password - The corresponding password of that account
- Local File - The local file that will be uploaded. Note that we used the %LocalPath% variable. In this particular context, this variable contains the complete local path of the file that was recently uploaded
- Remote Directory - A virtual path on the remote server. Forward slash (/) stands for the root directory of the account used for logging in.
Leave the rest of the settings as is for now and click the OK button to proceed.
You should then see your newly created trigger action among the list of trigger actions. In this case, there's only one. Click OK to proceed.
Once you're back at the main screen, you should see your newly created trigger. Make sure you click the Apply button to save those settings.
4B. (Alternative) Add the Trading Partner File Upload trigger action
If you already have an existing SFTP trading partner, you can use Trading Partner File Upload instead of SFTP File Upload for your trigger action. Using a trading partner entity offers significant benefits.
Read the article Preparing Trading Partner Servers For SFTP Automation to understand their advantages as well as to learn how to set up a trading partner for SFTP.
5B. Enter the necessary trigger action parameters
Because this is a trading partner-based trigger action, there's no need to specify the hostname, port number, username, and password. Just select the trading partner from the drop-down list and then specify the local file and remote directory. See section 5 above for brief descriptions of these parameters.
Here's that newly added trigger action again.
Again, when you get back to the main screen, don't forget to click the Apply button.
That's it. Easy as pie. All files that will be uploaded to this server via FTP will be automatically forwarded to the remote SFTP server.
Want to try this out yourself? Download a free, fully-functional evaluation edition of JSCAPE MFT Server now.