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.
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.