Post a reply

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

Sasidharan9513

winscp .NET assembly open sftp session with out Hostkey

Hi There,

I am getting the below error when I am open a session with out giving the Host key informtion.

"SessionOptions.Protocol is Protocol.Sftp , but SessionOptions.HostKey is not set."

Is is possible to open a sftp session with out giving a host key or host key is a must?


My Code :

SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "example.com",
UserName = "username",
Password = "password"
};

using (Session session = new Session())
{
// Connect
session.DisableVersionCheck = false;
session.Open(sessionOptions); ---- get error in this line since I am not giving Host Key info
}



Regards,
S.Sasidharan