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
Deserializing Json Data to C# Using Json.Net
If Async-Await Doesn't Create Any Additional Threads, Then How Does It Make Applications Responsive
Transparent Control Over Picturebox
Difference Between Shadowing and Overriding in C#
Find Control by Name from Windows Forms Controls
How to Get the Cpu Usage in C#
Is There Any Significant Difference Between Using If/Else and Switch-Case in C#
How to Handle Accessviolationexception
A Generic Error Occurred in Gdi+, Jpeg Image to Memorystream
How to Specify a Custom Location to "Search For Views" in ASP.NET MVC
How to Split CSV Whose Columns May Contain ,
C# Data Connections Best Practice
How to Check For Internet Connectivity Using .Net
Json.Net Serialization of Type With Polymorphic Child Object
When Should I Use a List VS a Linkedlist
What's the Main Difference Between Int.Parse() and Convert.Toint32