Post a reply

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)


Topic review


Re: Fail to Connect SFTP

martin wrote:

You have to set TunnelHostKey too:

It works!
I have add this code as your suggest
  sessionOptions.AddRawSettings("TunnelHostKey", "ssh-rsa 1024 xxx")

thank you so much for your help

Fail to Connect SFTP


Connecting using winscp it self is OK, but i got a problem whent connecting to SFTP using winscp Library.
Below is the error i got when try to connect
Expected host key was not configured, use -hostkey switch.
Host key fingerprint is xxxx.
Authentication failed.

And this is my code, i got this using menu "Session>>Generate Session URL/code"
' Set up session options

        Dim sessionOptions As New SessionOptions
        With sessionOptions
            .Protocol = Protocol.Sftp
            .HostName = ""
            .UserName = "username"
            .Password = "password"
            .SshHostKeyFingerprint = "ssh-rsa 1024 xxx"
        End With

        sessionOptions.AddRawSettings("Tunnel", "1")
        sessionOptions.AddRawSettings("TunnelHostName", "")
        sessionOptions.AddRawSettings("TunnelUserName", "user")
        sessionOptions.AddRawSettings("TunnelPublicKeyFile", "C:%5CUsers%5CAdministrator%5CDesktop%5CFile.ppk")

        Using session As New Session
            ' Connect

            ' Your code
        End Using

Please advice how to fix this,

Thank you