Re: Revolving Host Key Error
Martin,
Thank you! That did the trick.
-BHanson
Thank you! That did the trick.
-BHanson
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
SessionOptions.SshHostKeyFingerprint. Separate the host keys by semicolons.
SshHostKeyFingerprint =
"ecdsa-sha2-nistp256 256 1111111111111111111111111111;" +
"ecdsa-sha2-nistp256 256 2222222222222222222222222222;" +
"ecdsa-sha2-nistp256 256 3333333333333333333333333333";
"ecdsa-sha2-nistp256 256 1111111111111111111111111111" and it will say I need to switch to "ecdsa-sha2-nistp256 256 222222222222222222222222222".
222222 and it will say bad key, you need to use "ecdsa-sha2-nistp256 256 33333333333333333333333333333"
"ecdsa-sha2-nistp256 256 33333333333333333333333333333" and it works.
"ecdsa-sha2-nistp256 256 33333333333333333333333333333" and the error says I need to use "ecdsa-sha2-nistp256 256 222222222222222222222222222"
SshHostKeyFingerprint. I am experienced .NET developer but new to SFTP and WinSCP.
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "aaaaa",
PortNumber = 22,
UserName = "bbbbb",
Password = "ccccc",
//SshHostKeyFingerprint = "ecdsa-sha2-nistp256 256 1111111111111111111111111111"
SshHostKeyFingerprint = "ecdsa-sha2-nistp256 256 222222222222222222222222222"
//SshHostKeyFingerprint = "ecdsa-sha2-nistp256 256 33333333333333333333333333333"
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(@"\\from directory\*", "/To sftp directory/In/", false, transferOptions);
// Throw on any error
transferResult.Check();
}