Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

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.