I had a similar problem and finally managed to fix it.
Below the solution:
1)Make sure following directives added to the solution
using Renci.SshNet;
using Renci.SshNet.Security;
using SshNet.Security.Cryptography;
2)Create the connectionInfo object and add necessary HostKeyAlgorithms in it.
var methods = new List<AuthenticationMethod>
{
new PasswordAuthenticationMethod("username", "password")
};
var connectionInfo = new ConnectionInfo("host", "username", methods.ToArray());
connectionInfo.HostKeyAlgorithms.Clear();
//ssh-ed25519
connectionInfo.HostKeyAlgorithms.Add("ssh-ed25519", (data) => { return new KeyHostAlgorithm("ssh-ed25519", new ED25519Key(), data); });
//ecdsa-sha2-nistp256
connectionInfo.HostKeyAlgorithms.Add("ecdsa-sha2-nistp256", (data) => { return new KeyHostAlgorithm("ecdsa-sha2-nistp256", new EcdsaKey(), data); });
//ecdsa-sha2-nistp384
connectionInfo.HostKeyAlgorithms.Add("ecdsa-sha2-nistp384", (data) => { return new KeyHostAlgorithm("ecdsa-sha2-nistp384", new EcdsaKey(), data); });
//ecdsa-sha2-nistp521
connectionInfo.HostKeyAlgorithms.Add("ecdsa-sha2-nistp521", (data) => { return new KeyHostAlgorithm("ecdsa-sha2-nistp521", new EcdsaKey(), data); });
//ssh-rsa
connectionInfo.HostKeyAlgorithms.Add("ssh-rsa", (data) => { return new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data); });
//ssh-dss
connectionInfo.HostKeyAlgorithms.Add("ssh-dss", (data) => { return new KeyHostAlgorithm("ssh-dss", new DsaKey(), data); });
3)Connect to desired sftp host using connectionInfo
var sftp = new SftpClient(connectionInfo);
using (sftp)
{
try
{
sftp.Connect();
Console.WriteLine("Connected");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}