Automating SFTP for CSV FIles

As part of its HRIS integration strategy, Dual Code provides a secure ftp server (SFTP) where user .csv files can be uploaded for import into your LMS.Ā In most cases, this .csv file will be exported from your HRIS and written to a local folder, or a folder on a secondary on-premise server.Ā  Ā It is also possible that your .csv file could originate from Active Directory (AD) or even be produced by an ETL process (SSIS).

It is up to your organization's IT administrator to upload this file from your on-premise server onto the Dual Code sftp server.Ā Since most organizations would not want to perform this task manually each time, here are a couple of examples showing how you could set up an automatic, scheduled upload of your .csv file:

Step-by-step Guide

For Windows

One option to schedule automatic file uploads in windows is to use WinSCP (https://winscp.net/eng/index.php).Ā You will need to ensure your Private SSH key is in the Private Putty Key (.ppk) format. Ā You can use the PuTTYgen tool to convert your OpenSSH formatted private key to the .ppk format.

To set up WinSCP:

  1. Create a new session and save it with a meaningful name making sure you can connect using the secure key.

  2. Once connected, you can use ā€˜Keep Remote Directory up to Date...ā€™ feature under the ā€˜Commandsā€™ menu.

  3. This will watch a specified directory for any changes and if so, upload the changed file.



Another option using also WinSCP is use this Powershell command and have it run periodically using the task scheduler:

.\winscp.com /privatekey=C:\path\to\your\ssh\key\id_rsa.ppk /command "open sftp://siteaccountname@secureftp.dualcode.com/" "put """C:\path\to\your\user\upload\file.csv""" /uploads/" "exit"

In the example above, the beginning '.\' is the directory path of 'winscp.com'.

For Linux

This command will upload the selected file to the sftp server.

sftp [username]@secureftp.dualcode.com:uploads <<< $'put /path/to/csv/output/users.csv'



You can then schedule automatic uploads by adding the above command to your crontab (using the "crontab -e" command)

0 1 * * * * sftp [username]@secureftp.dualcode.com:uploads <<< $'put /path/to/csv/output/users.csv'