Utilizing SFTP within SSIS



Similar documents
Using sftp in Informatica PowerCenter

Connecting to the School of Computing Servers and Transferring Files

Management, Logging and Troubleshooting

Secure File Transfer Protocol User Guide. Date Created: November 10, 2009 Date Updated: April 14, 2014 Version: 1.7

WinSCP PuTTY as an alternative to F-Secure July 11, 2006

Access Instructions for United Stationers ECDB (ecommerce Database) 2.0

Accessing the FTP Server - User Manual

TS-800. Configuring SSH Client Software in UNIX and Windows Environments for Use with the SFTP Access Method in SAS 9.2, SAS 9.3, and SAS 9.

Install and configure SSH server

SOSFTP Managed File Transfer

SAS 9.4 In-Database Products

File Transfer Examples. Running commands on other computers and transferring files between computers

HPCC - Hrothgar Getting Started User Guide

Secure Shell SSH provides support for secure remote login, secure file transfer, and secure TCP/IP and X11 forwarding. It can automatically encrypt,

IBM Campaign and IBM Silverpop Engage Version 1 Release 2 August 31, Integration Guide IBM

FL EDI SECURE FTP CONNECTIVITY TROUBLESHOOTING GUIDE. SFTP (Secure File Transfer Protocol)

Implementing a Data Warehouse with Microsoft SQL Server

Published. Technical Bulletin: Use and Configuration of Quanterix Database Backup Scripts 1. PURPOSE 2. REFERENCES 3.

SFTP (Secure Shell FTP using SSH2 protocol)

COURSE 20463C: IMPLEMENTING A DATA WAREHOUSE WITH MICROSOFT SQL SERVER

Implementing a Data Warehouse with Microsoft SQL Server

Backup/Restore Microsoft SQL Server 7.0 / 2000 / 2005 / 2008

Secure File Transfer Protocol User Guide

Centers for Medicare and Medicaid Services. Connect: Enterprise Secure Client (SFTP) Gentran. Internet Option Manual

Implementing a Data Warehouse with Microsoft SQL Server 2012 (70-463)

Windows PowerShell Cookbook

GS1 Trade Sync Connectivity guide

Microsoft. Course 20463C: Implementing a Data Warehouse with Microsoft SQL Server

Implementing a Data Warehouse with Microsoft SQL Server

File transfer clients manual File Delivery Services

IBM Security QRadar Version Vulnerability Assessment Configuration Guide IBM

Secure Data Transfer

Implement a Data Warehouse with Microsoft SQL Server 20463C; 5 days

PROCESSES LOADER 9.0 SETTING. Requirements and Assumptions: I. Requirements for the batch process:

Microsoft Windows PowerShell v2 For Administrators

DigiVault Online Backup Manager. Microsoft SQL Server Backup/Restore Guide

Implementing a Data Warehouse with Microsoft SQL Server 2012

LICENSE4J FLOATING LICENSE SERVER USER GUIDE

Global TAC Secure FTP Site Customer User Guide

Editing Locally and Using SFTP: the FileZilla-Sublime-Terminal Flow

Methods available to GHP for out of band PUBLIC key distribution and verification.

WinSCP for Windows: Using SFTP to upload files to a server

Configuring SSH and Telnet

Oracle Tutorial. Outline: Login to oracle server Create account Use SQL*PLUS Use SQL Developer (recommended)

File Transfer Protocol (FTP) & SSH

ICE Futures Europe. AFTS Technical Guide for Large Position Reporting V1.0

Send Video Recordings from the DVR to a FTP Server on your PC

IBM Campaign Version-independent Integration with IBM Engage Version 1 Release 3 April 8, Integration Guide IBM

Using IKEv2 on Juniper Networks Junos Pulse Secure Access Appliance

smartoci User Guide Secure FTP for Catalog Loads

SQL Server Introduction to SQL Server SQL Server 2005 basic tools. SQL Server Configuration Manager. SQL Server services management

Sysax Multi Server User manual

2 Advanced Session... Properties 3 Session profile... wizard. 5 Application... preferences. 3 ASCII / Binary... Transfer

Implementing a Data Warehouse with Microsoft SQL Server 2014

XFTP 5 User Guide. The Powerful SFTP/FTP File Transfer Program. NetSarang Computer Inc.

FL EDI SECURE FTP CONNECTIVITY TROUBLESHOOTING GUIDE. SSL/FTP (File Transfer Protocol over Secure Sockets Layer)

CERULIUM TERADATA COURSE CATALOG

Netop Remote Control Security Server

List of FTP commands for the Microsoft command-line FTP client

Secure Shell. The Protocol

Cloud Backup Express

Instructions for Setup and Connecting to Department of Education Secure FTP(SFTP) server January 23, 2013

Implementing a Data Warehouse with Microsoft SQL Server MOC 20463

COURSE OUTLINE MOC 20463: IMPLEMENTING A DATA WAREHOUSE WITH MICROSOFT SQL SERVER

Uploading and Downloading Files to the HIS Server. Application Requirements

Managed File Transfer with Universal File Mover

Configuring and Monitoring Citrix Branch Repeater

SSH Secure Client (Telnet & SFTP) Installing & Using SSH Secure Shell for Windows Operation Systems

Configuring and Tuning SSH/SFTP on z/os

Quick Start Guide. Cerberus FTP is distributed in Canada through C&C Software. Visit us today at

What s New in Centrify Server Suite 2014

Enterprise Content Management System Monitor. Server Debugging Guide CENIT AG Bettighofer, Stefan

Quick Reference Guide. Online Courier: FTP. Signing On. Using FTP Pickup. To Access Online Courier.

Rstudio Server on Amazon EC2

WINGS WEB SERVICE MODULE

Network Management Card Security Implementation

Submitting UITests at the Command Line

Step-by-Step Guide to Active Directory Bulk Import and Export

SSIS Training: Introduction to SQL Server Integration Services Duration: 3 days

Overview. Remote access and file transfer. SSH clients by platform. Logging in remotely

Configuring and Monitoring Citrix Access Gateway-Linux Servers. eg Enterprise v5.6

Network Security Essentials Chapter 5

WWA FTP/SFTP CONNECTION GUIDE KNOW HOW TO CONNECT TO WWA USING FTP/SFTP

Implementing a Data Warehouse with Microsoft SQL Server

East Asia Network Sdn Bhd

Directory and File Transfer Services. Chapter 7

CONNECTING TO DEPARTMENT OF COMPUTER SCIENCE SERVERS BOTH FROM ON AND OFF CAMPUS USING TUNNELING, PuTTY, AND VNC Client Utilities

Ad Hoc (Temporary) Accounts Instructions

Server Security. Contents. Is Rumpus Secure? 2. Use Care When Creating User Accounts 2. Managing Passwords 3. Watch Out For Aliases 4

Getting Started with STATISTICA Enterprise Programming

Exam Number/Code: Exam Name: Implementing a Data. Version: Demo. Warehouse with Microsoft SQL Server 2012

CAIL Security Facility NSK Host to Host FTP Encryption

Application note: Connecting the to a Database

agileworkflow Manual 1. agileworkflow 2. The repository 1 of 29 Contents Definition

ASX SFTP External User Guide

File Transfer. User Guide For Clients and Vendors. Last Revised: October

Using

How to Backup XenServer VM with VirtualIQ

SSL Tunnels. Introduction

Transcription:

Utilizing SFTP within SSIS By Chris Ware, Principal Consultant, iolap, Inc. The Problem Within SSIS a FTP task exists which enables you to access a FTP server. However, it does not support Secure FTP (SFTP). There are many Secure FTP tools to choose from and each requires a unique set of commands and designs to be used within SSIS. For this article, I am using Putty's file transfer tool commonly known as PSFTP (a free open source tool from www.putty.org). This tool performed as needed and we were able to build additional processes around it to enhance its use and satisfy our customers' requirements. The Task We needed to create a process in which the SSIS package looks at existing XML files in the data warehouse and determines which XML files need to be pulled from the external FTP location. After importing these files, a series of checks and balances take place ending with loading the file(s) into a SQL Server database. Please note: 1. The FTP location does not allow the removal of the XML files from the directory. 2. The FTP location contains up to 6 months of XML files. 3. The FTP location only supports Secure FTP. 4. There is a possibility of single or multiple files to be pulled at any given time.

The Process Create Variables MaxXMLDateString (Create as an "Object" Data type) SQL_Query (String Data type created to store the SQL statement) XML_Datekey (String Data type created to store the date pulled from the FTP location) Create SQL Table If you have an existing table for your process that stores the file names, then this table can be utilized to look for the appropriate file. If you do not have an existing SQL table to facilitate this then you will need to create a simple table that will hold the Filename and any other pertinent fields related to this execution process. Step 1 Build a list of the files that you need to pull. This is accomplished by creating a "Script Task." The purpose for this task is to query the datbase in which the processed XML files names exist and extract the latest date part from the filename so that it can be used to extract the needed file(s) from the FTP location. DB File format: IO701_20121020_59249.xml Task Output: 20121020 Public Sub Main() ' Dts.Variables("SQL_Query").Value = "select convert(varchar,datekey,112) datekey from db.dbo.dim_date where datekey between (Select substring(max(substring(filename, CHARINDEX('IO701',filename),24)),7,8)+1 From db.dbo.importaudit) and CONVERT(varchar,getdate(),112)" ' Dts.TaskResult = ScriptResults.Success End Sub

Step 2 Run the query created in Step 1 using the "Execute SQL Task." Set the Result Set to "Full Result Set" to capture everything from the SQL. On the "Result Set" selection (see below), insert the variable name and the Result Name as 0.

Step 3 Create a "Foreach Loop" that will use the value queried from the database (shown here as the "User::MaxXMLDateString") to select the appropriate XML files from the FTP site at runtime. This must be done using an ADO object source variable and shown below.

Below in the "Variable Mappings" section, the variable "User::XML_Datekey" is set and will hold each iteration of the value returned from the Foreach loop at run time.

Step 4 Embedded within the "Foreach Loop" is an "Execute Process Task" that contains the call to the.bat script that will essentially make the call to the external FTP site. Use expressions here to pass all of the arguments requested by the FTP site. The path to the executable and the working directory are also shown. These expressions are shown in the illustration below.

Step 5 Create your.bat file for PSFTP to handle the credentials and daily maintenance (i.e. file existence checks). Within the Parent batch file will be code used to create the iolap_get.bat " REM [DYNAMICALLY BUILDS THE GET BATCH FILE]" The last line contains the code that makes the SFTP call. Notice that the user and password information is parameterized. We are also asking SFTP to provide an outputfile and an errorfile. Additionally we have turned on the Verbose setting "-v" to get a more detailed result in each file.

REM [BUILDS THE XML FILENAME] set scriptsdir=d:\work\projects\ set Filename=IO701_%1 REM [BUILDS THE FTP OUTPUT LOG FILES] set OUTPUTFILE=%scriptsdir%OUTPUTFILE.log set ERRORFILE=%scriptsdir%ERRORFILE.log ECHO %Filename% REM [CHECKS FOR THE EXISTENCE OF THE GET BATCH FILE] IF EXIST %scriptsdir%iolap_get.bat rm %scriptsdir%iolap_get.bat REM [DYNAMICALLY BUILDS THE GET BATCH FILE] ECHO lcd>>%scriptsdir%iolap_get.bat D:\Work\Projects>>%scriptsdir%iolap_get.bat ECHO. >>%scriptsdir%iolap_get.bat ECHO mget>>%scriptsdir%iolap_get.bat %Filename%*.xml>>%scriptsdir%iolap_get.bat ECHO. >>%scriptsdir%iolap_get.bat ECHO quit>>%scriptsdir%iolap_get.bat ECHO. >>%scriptsdir%iolap_get.bat echo y psftp %2 -pw %3 -i "%KEY%" >"%OUTPUTFILE%" 2>"%ERRORFILE%" -v -b "D:\Work\Projects\iolap_get.bat" The Result On execution, SSIS will start and the Foreach Loop will extract the max value in the SQL table. It will then begin to search the FTP site and return all XML that is beyond the max date string based on the SQL query. (We set the SQL query as greater than the max but less than the current time) One by one it will match it to the date part of the file in the FTP location. If it finds a match, it will extract that file and then continue on to the next value until it has exhausted all of the values in the local directory between the max and current dates.

At this point you can continue your normal processing as needed. Upon successful completion of the load process you can update your SQL table with the file names that were processed as seen below in the "Local Directory After SFTP." Subsequent executions will begin from this point. Local Directory Before SFTP External FTP Site Local Directory After SFTP IO701_20130101_64962.xml IO701_20130101_64962.xml IO701_20130101_64962.xml IO701_20130105_65340.xml IO701_20130105_65340.xml IO701_20130105_65340.xml IO701_20130111_66066.xml IO701_20130111_66066.xml IO701_20130111_66066.xml IO701_20130118_66616.xml IO701_20130118_66616.xml IO701_20130118_66616.xml IO701_20130126_67174.xml IO701_20130126_67174.xml IO701_20130126_67174.xml IO701_20130201_67690.xml IO701_20130201_67690.xml IO701_20130201_67690.xml IO701_20130208_68534.xml IO701_20130208_68534.xml IO701_20130208_68534.xml IO701_20130215_69107.xml IO701_20130215_69107.xml IO701_20130222_69738.xml IO701_20130222_69738.xml (Max Value) IO701_20130301_70317.xml IO701_20130301_70317.xml 20130208 IO701_20130308_71207.xml IO701_20130308_71207.xml IO701_20130315_71905.xml IO701_20130315_71905.xml (Current Value) IO701_20130322_72569.xml IO701_20130322_72569.xml 20130330 IO701_20130329_73169.xml IO701_20130329_73169.xml SSIS pulls all values from 20130208 forward where available OUTPUTFILE.log Example (No Match): Connected to ftp.myftpsite.com Remote working directory is / New local directory is D:\Work\Projects\ IO701_20130618*.xml: nothing matched OUTPUTFILE.log Example (Match Found): Connected to ftp.myftpsite.com Remote working directory is / New local directory is D:\Work\Projects\ IO701_20130618*.xml

ERRORFILE.log Example (On Success): Looking up host "ftp.myftpsite.com" Connecting to 192.168.92.99 port 22 Server version: SSH-2.0-WS_FTP-SSH_7.1 Using SSH protocol version 2 We claim version: SSH-2.0-PuTTY_Release_0.62 Using Diffie-Hellman with standard group "group14" Doing Diffie-Hellman key exchange with hash SHA-1 Host key fingerprint is: ssh-rsa 1024 d5:d4:3a:b8:db:07:d9:bf:da:90:3a:c9:76:22:0a:99 Initialised AES-256 CBC client->server encryption Initialised HMAC-SHA1 client->server MAC algorithm Initialised AES-256 CBC server->client encryption Initialised HMAC-SHA1 server->client MAC algorithm Using username "00123456789@ssh". Sent password Access granted Opened channel for session Started a shell/command Sent EOF message Disconnected: All channels closed ERRORFILE.log Example (On Failure): Fatal: Server unexpectedly closed network connection Below is a screenshot of the completed SSIS section of the job and the tasks described above.

About the Author Chris Ware is a Principal Consultant at iolap, Inc., with a focus on ETL. He began his career providing analysis support and reporting in marketing and then insurance for a major retailer. Chris has had the opportunity to work within many different verticals throughout his data warehousing career using a variety of different integration tools. He feels that because data integration is ever changing that the opportunity to employ new processes is endless.