Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Connecting to FTP Server Using an SFTP Library

Post Author: Joe D365 |

For integrations between Microsoft Dynamics CRM and other systems (e.g. between CRM and ERP systems, Commerce Systems, custom systems, and even legacy main frame systems), the primary requirement is often to get or send data via FTP. However, FTP is plain text and insecure. For this reason, it is always best to use SFTP. So, let's talk about how you securely transfer your data utilizing Dot Net and SFTP.

Creating a connection to an SFTP server from Dot Net code is not easily done out of the box, but is easily done with a 3rd party DLL – SSH.net. In order to accomplish this you will need to download the SSH.Net Library from Codeplex at http://sshnet.codeplex.com/. After downloading library, you will need to build it and add the reference (Renci.SshNet.dll) to the project. Make sure to use the SftpClient class available in SSH.Net to connect to FTP Server using SFTP.

Steps To Connect to FTP Server Using SFTP:

  • Add the authentication information, path of the file on the FTP server in the configuration file as shown below.

    Microsoft Dynamics CRM and Connecting to FTP Server using SFTP

  • Add the reference to SSH.Net Library Dll to the project.

  • We will use the SftpClient class available in SSH.Net to connect to the FTP server. The screenshot below shows the code on how we connect to Ftp Server

The advantage of using SFTP is that your data is always kept secure while in transit. This is essential if dealing with anything confidential such as HIPPA data.

Happy "secure" CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

8 comments on “Connecting to FTP Server Using an SFTP Library”

  1. Any ideas how to use renchi in order to connect to an FTP and not an SFTP ?

      1. Thanks Joe for your reply. I was asking if that is the case, b/c my solution will consider both cases: clients using SFTP and clients using FTP, and none of the libraries can't handle both cases. So in my application I'm using both approachs: Renci for SFTP and FTPWebRequest for FTP.

        Regards.

  2. @alexfagundes:disqus can we connect CRM 2013 to a local private ftp server in order to host folders containing attachments( pictures,documents,videos) for multiple entities in CRM where each client has a specific folder in the local private ftp server ?

  3. I used Renci.Sshnet V 1.0.0.0 Bids 2008 R2 its working fine. Same package I configured sql agent its getting fail due to timeout and i set timeout period 60 sec in my code. how to resolve this?

  4. Does this work with CRM 2016 Online? I'm trying to hit a SFTP endpoint and get a CSV file.

    Thanks!

PowerObjects Recommends