Sftp Libraries For .Net

OpenSource .NET library for connecting to SFTP server?

SharpSSH

SFTP library for .NET?

I currently use WinSCP. It has a .NET assembly that can be used to programmatically create and manage SFTP, SCP, FTP, and WebDAV connections.

Here's an example from their documentation:

using System;
using WinSCP;

class Example
{
public static int Main()
{
try
{
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "example.com",
UserName = "user",
Password = "mypassword",
SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
};

using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult;
transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions);

// Throw on any error
transferResult.Check();

// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}

return 0;
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
return 1;
}
}
}

Does .NET Core 2.0 have SFTP client?

There's no SFTP client in any current (nor past) version of .NET.

See also SFTP Libraries for .NET and many others.

SFTP with .NET 3.5

There are commercial solutions:

  • http://www.rebex.net/sftp.net/
  • http://www.enterprisedt.com/products/edtftpnetpro/overview.html

...and free:

  • http://www.tamirgal.com/blog/page/SharpSSH.aspx

I personally have no experience with any of them.



Related Topics



Leave a reply



Submit