(Complete Novice) SshHostKeyFingerprint error
I'm using WinSCP from within a C# WinForms app being developed in Visual Studio 2022 in Win10.
The app is for TLS/SSL cert auto renewal; FTP sessions will occur every 60–90 days and the sessions will only be open for 5–10 minutes (depending on host response times).
I can connect with the following (verified with a directory read):
Even though vulnerability to malicious attack is limited in this situation I would prefer a secure session. Lacking a host fingerprint I obtained it via
I then ran:
which throws this error:
I've obviously misunderstood something ... any help will be appreciated.
Art H.
The app is for TLS/SSL cert auto renewal; FTP sessions will occur every 60–90 days and the sessions will only be open for 5–10 minutes (depending on host response times).
I can connect with the following (verified with a directory read):
SessionOptions so = new SessionOptions(); so.HostName = "server220.web-hosting.com"; so.UserName = "id"; so.Password = "pw"; so.PortNumber = 21; so.Protocol = Protocol.Ftp; using (Session sess = new Session()){//do work}
sess.ScanFingerprint(so, "SHA-256")
which returned: 16:c0:dd:71:d3:9a:18:be:3f:7a:ed:68:69:c5:71:d6:ba:03:dc:15:82:58:0b:dd:5d:27:3a:58:c1:03:b8:e5
SessionOptions so = new SessionOptions(); so.HostName = "server220.web-hosting.com"; so.UserName = "id"; so.Password = "pw"; so.PortNumber = 21; so.Protocol = Protocol.Sftp; so.FtpSecure = FtpSecure.Explicit; so.SshHostKeyFingerprint = "ssh-rsa 2048 16:c0:dd:71:d3:9a:18:be:3f:7a:ed:68:69:c5:71:d6:ba:03:dc:15:82:58:0b:dd:5d:27:3a:58:c1:03:b8:e5"; using (Session sess = new Session()){// do work}
FTP conncct error:: System.ArgumentException: SSH host key fingerprint "ssh-rsa 2048 16:c0:dd:71:d3:9a:18:be:3f:7a:ed:68:69:c5:71:d6:ba:03:dc:15:82:58:0b:dd:5d:27:3a:58:c1:03:b8:e5" does not match pattern /((ssh-rsa|ssh-dss|ssh-ed25519|ecdsa-sha2-nistp(256|384|521))( |-))?(\d+ )?(([0-9a-fA-F]{2}(:|-)){15}[0-9a-fA-F]{2}|[0-9a-zA-Z+/\-_]{43}=?)(;((ssh-rsa|ssh-dss|ssh-ed25519|ecdsa-sha2-nistp(256|384|521))( |-))?(\d+ )?(([0-9a-fA-F]{2}(:|-)){15}[0-9a-fA-F]{2}|[0-9a-zA-Z+/\-_]{43}=?))*/ at WinSCP.SessionOptions.SetSshHostKeyFingerprint(String s) at WinSCP.SessionOptions.set_SshHostKeyFingerprint(String value) at App_UI.Context..ctor(String[] tsArgs) in E:\TLS_SSL Cert Renewal\App_UI\Context.cs:line 58
Art H.