Posted: 2016-08-26 16:46
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?
Private Sub Upload(ByRef mySession As Session)
' Setup session options
Dim mySessionOptions As New SessionOptions
.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"
' 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"
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
And it's free!