Failed to store new host key
Hi,
We are using WinSCP nuget (version: 5.19.3) in our project.
WinSCP nuget is used to connect to a SFTP server from Microsoft Azure function.
Our Microsoft Azure function is a timer trigger function. We are using C# .NET in the timer trigger function.
Our Azure function is working fine in local, but when we have hosted to Azure cloud it is giving below exception when trying to connect to the SFTP server.
Exception:
We are using WinSCP nuget (version: 5.19.3) in our project.
WinSCP nuget is used to connect to a SFTP server from Microsoft Azure function.
Our Microsoft Azure function is a timer trigger function. We are using C# .NET in the timer trigger function.
Our Azure function is working fine in local, but when we have hosted to Azure cloud it is giving below exception when trying to connect to the SFTP server.
Exception:
Our Code:Messsage: Failed to store new host key. Authentication failed.
Exception type: WinSCP.SessionRemoteException
Failed Method: WinSCP.SessionLogReader.Read
SessionOptions sessionOptions = new SessionOptions { Protocol = Protocol.Sftp, HostName = "xxx", UserName = "xx", Password = "xxx", PortNumber = "xx", SshHostKeyPolicy = SshHostKeyPolicy.AcceptNew }; using (session = new Session()) { session.Open(sessionOptions); TransferOptions transferOptions = new TransferOptions(); transferOptions.TransferMode = TransferMode.Binary; transferOptions.ResumeSupport.State = TransferResumeSupportState.Off; var localTempPath = $"{Directory.GetCurrentDirectory()}\\{ sftpServer.SFTP.FileName}"; // Download the file TransferOperationResult transferOperationResult = session.GetFiles($"{ sftpServer.SFTP.Directory}{ sftpServer.SFTP.FileName}", localTempPath, false, transferOptions); // Read the file result = File.ReadAllLines(localTempPath).Select(v => ImportSampleModel.FromCsv(v)).ToList(); // Delete the file File.Delete(localTempPath); }