Topic "Host Key Does not Match Configured Key Error"

Author Message


I am using VBA to upload SFTP files into excel from WinSCP
The code below is modified from the example to match my requirements:

Now in the code below, i have removed the actual host, username and passwords due to security, but I do utilize them when running the code.
The host key fingerprint i have, i obtained form putty gen, when the key was generated. It follows the "Ssh-rsa 2048" format with 16 number pairs followed. separated by the colons.

When I get the error however, it only shows 14 pairs, even though my code has 16.
Not sure if there is anything else wrong in this code either. How can I proceed past this error?

Many thanks

Private Sub Upload(ByRef mySession As Session)
    ' Setup session options
    Dim mySessionOptions As New SessionOptions

    With mySessionOptions
        .Protocol = Protocol_Sftp
        .HostName = "My host name goes here"
        .UserName = "Username goes here"
        .Password = "password goes here"
        .SshHostKeyFingerprint = "ssh-rsa 2048 93:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
    End With
    ' Connect
    mySession.Open mySessionOptions
    ' Upload files
    Dim myTransferOptions As New TransferOptions
    myTransferOptions.TransferMode = TransferMode_Binary
    Dim transferResult As TransferOperationResult
    Set transferResult = mySession.GetFiles("/reports/*", "F:\SFTP", False, myTransferOptions)
    ' Throw on any error
    ' Display results
    Dim transfer As TransferEventArgs
    For Each transfer In transferResult.Transfers
        MsgBox "Upload of " & transfer.Filename & " succeeded"
End Sub
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
The PuTTYgen does not give you the host key. That's your account private key.


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