SFTP without using Host Key
I am doing SFTP(uploading files) using winscp through C# code.
If I'll provide argument hostname, username, hostkeyfingerprint & privatekeyfilepath, it works!!
but I want to do SFTP without passing argument hostkeyfingerprint , it fails with error: "sessionoptions host key is not set..."
So , is it possible to do SFTP without using "hostkeyfingerprint"
If possible, could anyone please let me know, how to achieve that.
Below is part of code:
--------------------------------------------------------------
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = varHostName,
UserName = varUserName,
PortNumber = 22,
SshPrivateKeyPath = varPrivatekeyFilePath,
SshHostKeyFingerprint = ???
};
using (Session session = new Session())
{
session.ExecutablePath = varExecutablePath; //location of winscp.exe
session.Open(sessionOptions);
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(@"" + varlocalPath + "\\" + "*.txt", varRemoteOutPath, false, transferOptions);
.........
}