Host Key Does not Match Configured Key Error

Advertisement

Guest216
Guest

Host Key Does not Match Configured Key Error

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
    transferResult.Check
     
    ' Display results
    Dim transfer As TransferEventArgs
    For Each transfer In transferResult.Transfers
        MsgBox "Upload of " & transfer.Filename & " succeeded"
    Next
    
End Sub

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum