How to access SFTP with SSIS using SSH.NET. I have been looking around for an all encompassing guide to setting up and connecting to an SFTP server with SSIS and have been unable to find such an article. After some trial and error, I have put together how I was able to accomplish accessing an SFTP server with SSIS using SSH.NET by Renci.

Configure SSIS

⦁ Make new SSIS Project
⦁ Next, add script tag to control flow
⦁ Then, edit script
⦁ Right click References and select ‘Manage NuGet Packages’

How to access SFTP with SSIS using SSH.NET - package install

⦁ After that, go to Browse and find the following to packages and versions
⦁ SSH.NET by Renci – 2016.0.0
⦁ SshNet.Security.Cryptography by Renci – 1.2.0

Needed packages

⦁ Right click on the project and select properties – I am using 4.5
c# version
⦁ Add the following name space to the script
⦁ using Renci.SshNet;
⦁ Add the following code to connect to the server and print out the files in the desired directory

Code for SFTP connection with SSH.NET

public void Main()
  // SFTP credentials – smart to make these SSIS variables and read them in
  var host = “”; //No “sftp://” prior to host
  var port = 2222;
  var username = “user”;
  var password = “pass”;

  var remoteDir = “/”; //This is the desired remote directory

  //Create client with credientials
  using (var client = new SftpClient(host,port,username,password))
  Console.WriteLine(“Connect to ” + host + ” as ” + username);

  //List files in target server directory
  var files = client.ListDirectory(remoteDir);

  Console.WriteLine(“Files in ” + remoteDir + “: “);

   foreach (var file in files)
    if (client.Exists(remoteDir + file.Name)) //Not needed
       Console.WriteLine(“Exists: ” + file.Name);

Dts.TaskResult = (int)ScriptResults.Success;

Great,  now we have all the base SSIS and C# looking good let’s try to run it!
Oh no! We get an error in the script!

Error: Could not load file or assembly ‘Renci.SshNet, Version=2016.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106’ or one of its dependencies. The system cannot find
the file specified.

Install packages to GAC manually

For some reason, SSIS does not automatically see the packages you installed. We need to manually download the dll’s now for our referenced packages and install them to the GAC (Global assembly cache). Go to the following links and download the packages.

How to access SFTP with SSIS using SSH.NET - packages website

Once they are downloaded, we can unzip the packages with 7-Zip. In the Downloaded package, > lib > netstandard1.3, I can see the dll that I want to manually add to the GAC.

Local Dll file
Open ‘Developer Command Prompt for VS 2017’ – and Run as Admin
Dev cmd prompt for VS2017
After that, run the following command for both packages
gacutil /i [PATH TO DLL] /f
How to access SFTP with SSIS using SSH.NET - manual package install to GAC
Now when we run our script we can see that the packages get recognized! In conclusion, we need to install the packages with NuGet, write our code to connect, then manually install the same versions of the dll’s so SSIS can see the packages we wish to use.

Now that we know how to access SFTP with SSIS using SSH.NET, we can write our script to pull files, check if files exist, delete files, push files, and more.

For more SSIS development blogs, read on!

For more tech blogs, subscribe to the code_marks news letter:



  1. Pingback: How to automate SSIS packages in SSMS | Marked Code

  2. Hello Team markedcode,
    many thanks for your post
    I follow these steps and works fine in my desktop , the dll is installed and i make a call for renci in my C# code and execution run is success.
    But i still have the problem in cloud , I need to install dll file in IR SSIS (azure) :
    my project is deplyed in Azure server and i should install the dll file (renci) in the global cache of IR SSIS . I follow your steps : I add a folder containing gacutil and the dll file in our specified blob storage , and i add the main.cmd in Azure with this code :
    gacutil\gacutil /i Renci.SshNet.dll /f
    gacutil\gacutil /i SshNet.Security.Cryptography.dll /f
    I don’t need any messages. After I restart IR SSIS and make an execution for my package (with ssis calatog) and still have this error :

    Could not load file or assembly ‘Renci.SshNet, Version=2016.0.0.0, Culture=neutral,
    PublicKeyToken=1cee9f8bde3db106’ or one of its dependencies. The system cannot find the file specified.

    I tried these solutions also with powershell :
    –> Not working

    Please any help ,

  3. It’s hard to come by knowledgeable people in this particular topic, but you sound like you know what you’re talking about! Thanks

Write A Comment