However, I got a error message "Host key wasn't verified!".
My script is as following.
I have added the public key on remote server.
And the host key in the script is the finger print of the private key.
The finger print is same between private key and public key.
There is no problem if I use WinSCP GUI to connect to the remote server.
Could anyone help me to fix the issue?
' Setup session options
Set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
.HostName = "test.com"
.UserName = "test"
.Password = "password"
.SshHostKey = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
Set session = WScript.CreateObject("WinSCP.Session")
' Upload files
Set transferOptions = WScript.CreateObject("WinSCP.TransferOptions")
'transferOptions.TransferMode = TransferMode.Binary
Set transferResult = session.PutFiles("c:\data\mylogfile.txt", ".", False, transferOptions)
' Throw on any error
' Print results
For Each transfer In transferResult.Transfers
WScript.Echo "Upload of " & transfer.FileName & " succeeded"
' Disconnect, clean up