SshHostKeyFingerprint in winscp

Advertisement

anjali
Joined:
Posts:
1
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