I want to connect to SFTP to download files from there. I can able to login into SFTP by using the credential via website and Command Prompt (using ftp command) as well. Now, I want to connect it from my .Net code using specific credential.
I am using SSH.NET with version 2020.0.1 and .Net Core Runtime version 3.1.18 and .Net Core SDK version 3.1.412 and OS is Windows (10.0.17763) 64 bit.
While trying to connect with SFTP via .Net Framework, I can doing it comfortably using same DLL version downloaded from NuGet. Now, when I am using same piece of code for .Net Core project, it is throwing exception. I have downloaded same package version from NuGet for .Net Core.
Below is my code:
public void Connect()
{
string host = "xxxx.xx.xxx";
int port = xx;
string userid = "xxxx";
string password = "xxxx";
try
{
Renci.SshNet.SftpClient client = new Renci.SshNet.SftpClient(host, port, userid, password);
if (!client.IsConnected)
{
client.ConnectionInfo.Timeout = TimeSpan.FromMinutes(1);
client.Connect();
Console.WriteLine("SFTP client connected successfully");
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
The exception message that I am getting when I am using .Net Core is as below:
Accessing a hash algorithm by manipulating the HashName property is not supported on this platform. Instead, you must instantiate one of the supplied subtypes (such as HMACSHA1.)
In which place I am doing mistake? Any help would be highly appreciated !!