VBScript – SshHostKeyFingerprint is not set

Advertisement

markf
Joined:
Posts:
2

VBScript – SshHostKeyFingerprint is not set

Good Morning.
I am creating a VBScript to upload files via FTP. I can connect with WinSCP GUI. When the script is run it gives the error
SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but the SessionOptions.SshHostKeyFingerprint is not set
The Generate session URL/Code for VB.NET is below:
' Set up session options
Dim sessionOptions As New SessionOptions
With sessionOptions
    .Protocol = Protocol.Ftp
    .HostName = "ftp.address.com"
    .PortNumber = 990
    .UserName = "username"
    .Password = "password"
    .FtpSecure = FtpSecure.Explicit
End With
 
sessionOptions.AddRawSettings("MinTlsVersion", "12")
 
Using session As New Session
    ' Connect
    session.Open(sessionOptions)
 
    ' Your code
End Using
The VBScript is below:
' Set up session options
Dim sessionOptions 
Set sessionOptions = CreateObject("WinSCP.SessionOptions")
With sessionOptions
    .Protocol = Protocol_Ftp
    .HostName = "ftp.address.com"
    .PortNumber = 990
    .UserName = "username"
    .Password = "password"
    .FtpSecure = FtpSecure_Explicit
End With
 
sessionOptions.AddRawSettings "MinTlsVersion", "12"
 
Dim session
Set session = CreateObject("WinSCP.Session")
 
' Connect
session.Open sessionOptions 
 
    ' Your code
I have tried adding the .SshHostKeyFingerprint and .TlsHostCertificateFingerprint to sessionOptions using the fingerprint from the Server and protocol information, only to receive the SSH host key fingerprint "xxx" does not match pattern, for the following iterations below:
SHA-256 2048 xx:xx:xx:xx... 
SSH-RSA 2048 xx:xx:xx:xx...
Thank you for your help.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,453
Location:
Prague, Czechia

Re: VBScript – SshHostKeyFingerprint is not set

For the Protocol_Ftp to work, your script needs to be WSF. Is it? Probably not, as the setting do not seem to have any effect, as WinSCP thinks, it's SFTP, not FTP, session.
See https://winscp.net/eng/docs/library_com_wsh#enums

Though you might still need to set TlsHostCertificateFingerprint, if your server's certificate is not signed by a trusted authority. What is quite common with FTPS server. The fingerprints you have posted are from SSH host keys. You could not got those from FTPS session.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,453
Location:
Prague, Czechia

Re: VBScript – SshHostKeyFingerprint is not set

You would have to use numerical values instead of all constants.
We recommend using .wsf instead.

Alternative approach is to consider the session via session URL and SessionOptions.ParseUrl:
sessionOptions.ParseUrl "ftpes://username:password@ftp.address.com:990"

Note that the combination of Explicit TLS and port 990 is suspicious. The port 990 is used by Implicit TLS. Are you sure your FTP server is misconfigured this way?

Reply with quote

Advertisement

You can post new topics in this forum