Topic "Problems with .NET SFTP connection"

Author Message
Phil Gameson
[View user's profile]

Joined: 2012-05-29
Posts: 2
Location: Birmingham, United Kingdom

I am trying to connect to an SFTP site for which I have been given a user id and password, but not an ssh host key.
Whilst I can connect successfully using the WINSCP front end, if I try connecting via the .NET assembly I either get a message telling me I need to supply a host key, or if I supply an null or empty ("") key I get "Host key wasn't verified".

Do I need to set another option if I am not providing an ssh host key?

I am using version 5.07.2268 WINSCP.exe and of WINSCP.dll.

The C# code I am using is something like:

Session sctpSession = new Session();
// Setup session options
SessionOptions sessionOptions = new SessionOptions
Protocol = (useSftp ? Protocol.Sftp : Protocol.Ftp),
HostName = ftpSite,
UserName = userName,
Password = password
,SshHostKey = "" // Tried commenting this out, but just got different error

// Connect
// session.DisableVersionCheck = true; // Not recommended!

I had this same issue and I believe that I used putty to get my host key.
Phil Gameson
[View user's profile]

Joined: 2012-05-29
Posts: 2
Location: Birmingham, United Kingdom
I am new to SFTP and am unsure how to use / get putty - as far as I can see this is not part of WINSCP itself.
Seeing that I can login to a particular SFTP using GUI without specifying a host key I feel that it must be possible to do the same using .NET. [However, looking at the documention, I am not so sure!]

From the documentation it looks like what I actually need is a fingerprint for the Ssh Host Key.
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27083
Location: Prague, Czechia
I have added topic to the FAQ:

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License