Alternative SshHostKeyFingerprint Formatting Issue

Advertisement

CB
Guest

Alternative SshHostKeyFingerprint Formatting Issue

Hello,

I am using the .NET assembly of WinSCP574 in a SSIS project to establish a SFTP connection. The issue I am having is related to the fingerprint of the server, especially when providing multiple possible fingerprints (multiple values for SshHostKeyFingerprint).

Everything works just fine using just one Key:

SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = (string) Dts.Variables["User::HostName"].Value,
UserName = (string) Dts.Variables["User::UserName"].Value,
Password = (string) Dts.Variables["User::Password"].Value,
PortNumber = (string) Dts.Variables["User::PortNumber"].Value,
SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
}

However, as soon as I add multiple SshHostKeyFingerprints with the following syntax, it fails:
SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx; ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"

The error message is, that the syntax doesn't match the pattern
((ssh-rsa|ssh-dss)( |-))?(\d+ )?([0-9a-f]{2}(:|-)){15}[0-9a-f]{2}(;((ssh-rsa|ssh-dss)( |-))?(\d+ )?([0-9a-f]{2}(:|-)){15}[0-9a-f]{2})*

In order to check that my syntax is correct, I did a check with Regex.Match, which returned true.

Am I missing anything? Is the current version of WinSCP still supporting multiple SshHostKeyFingerprints?

Thank you,
Christian

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Alternative SshHostKeyFingerprint Formatting Issue

While the Regex.Match.Success is indeed true, it does not match whole string, just the first hostkey.

The assembly does not accept the space after the semicolon. Remove it.

Reply with quote

Advertisement

You can post new topics in this forum