SFTP Libraries in C#

  1. C# SSH.NET
  2. WinSCP
  3. Rebex
SFTP Libraries in C#

SFTP stands for Secure File Transfer Protocol and performs various tasks for sensitive files. Examples for tasks you can do using SFTP would be:

  • Uploading/Downloading files between servers/computers
  • Deleting Files
  • Resuming Paused File Transfers

There are many available SFTP Libraries you can use. Here we will list a few examples of libraries and some of their features and benefits.

C# SSH.NET

SSH.NET is a Secure Shell (SSH) open-source library optimized for parallelism. The project was originally inspired by Sharp.SSH.

This library is consistently updated and highly recommended by other developers. As it is free to use, trying it out is easy and pain-free. There are also many available documentation and forums discussing how to use SSH.NET and help you troubleshoot errors. This library makes use of the MIT License.

Here are some of the features as advertised by SSH.NET:

  • Provides SCP functionality
  • Remote, dynamic, and local port forwarding
  • Provide SFTP functionality for both synchronous and asynchronous operations
  • Provide a status report for upload and download sftp operations to allow accurate progress bar implementation
  • Shell/Terminal implementation
  • Supports two-factor or higher authentication
  • Supports SOCKS4, SOCKS5, and HTTP Proxy
  • Supports public-key, password, and keyboard-interactive authentication methods
  • Specify key file pass phraseExecution of SSH command using both synchronous and asynchronous methods
  • Return command execution exit status and other information
  • Use multiple key files to authenticate

To use SSH.NET, you can either install it through the NuGet Package Manager or pull the project from GitHub.

WinSCP

WinSCP (Windows Secure CoPy) started out as a .NET wrapper but has since become a .NET Library.

This library is also consistently updated and well documented. As this library is also free and open-source, it is one of the SFTP Libraries commonly recommended in forums. This library makes use of the GNU General Public License and is free to use, redistribute and/or modify under the terms of the GPL.

Here are some features available in WinSCP:

  • Graphical User Interface
  • Available in many languages
  • Integrated with Windows
  • Supports all common file operations
  • Supports SFTP and SCP protocols over SSH and FTM and WebDav and S3 protocols
  • Allows batch file scripting and command-line interface and .NET assembly for advanced programming tasks
  • Directory synchronization in several semi or fully automatic ways
  • Has an Integrated Text Editor
  • Support for password, keyboard-interactive, public key and Kerberos (GSS) authentication
  • Integrates with Pageant (PuTTY authentication agent) for full support of public key authentication with SSH

To use WinSCP, you can either install it through the NuGet Package Manager or through their website at WinSCP.

Rebex

Rebex is a paid solution that offers both a File Transfer Pack, SSH Pack, or a Total Pack which provides all Rebex .NET components in one pack. This includes;

  • SFTP, FTP, HTTP, IMAP, POP3, SMPT, EWS, SNTP, WebSocket, Mail
  • TLS 1.3 on Windows 7, 8.1, 10, 11
  • SFTP and SSH Server
  • SSH Shell and Telnet with terminal emulation
  • Syslog client and server
  • ZIP and GZIP compression

While this library isn’t open-source, one of the benefits of choosing Rebex would be being able to access support from their team. They have a large set of Knowledge Base Articles to help you utilize the library. They also provide a 30-day free trial, so you can test and see if their solution is the best one for you.

For more information on Rebex, you can check out their website.