SshHostKeyFingerprint in WinSCP

Advertisement

anjali
Joined:
Posts:
3
Location:
anjali

SshHostKeyFingerprint in WinSCP

Hello All,

We have been using WinSCP for several years now in our Windows application. We recently decided to move our application to web. We already wrote the code in C#. The code is similar to the code in WinSCP documentation for .NET.

When we were transferring the file before, we were not using SshHostKeyFingerprint, but now with the new .NET code, I am getting an error asking for SshHostKeyFingerprint. Below is the error. Is it something new for .NET_
SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set
Below is the code that I am using:
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Sftp,
    HostName = "test",
    UserName = "test2",
    Password = "xyz",
    // SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx...="
};
 
using (Session session = new Session())
{
    // Connect
    session.Open(sessionOptions);
 
    // Upload files
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;
 
    TransferOperationResult transferResult;
 
    transferResult =
        session.PutFiles(@"\\apps-ds\data\" + fileName, "/transfer", false, transferOptions);
 
    // Throw on any error
    transferResult.Check();
 
    // Print results
    foreach (TransferEventArgs transfer in transferResult.Transfers)
    {
        Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
    }
}

any help will be greatly appreciated.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum