Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

goatmandude20

Re: C# Host key does not match configured key fingerprint

Thanks Martin. I had already read the info at the link you posted but it was still a good review. Turns out, it was my fault... I created two config files, one for testing and one for production. I copy/pasted the same URL for both...smh. After changing the URL for the production config file my program connects. Haha. Thanks for your reply.
martin

Re: C# Host key does not match configured key fingerprint

See https://winscp.net/eng/docs/faq_hostkey

If it does not help, please post complete session log files both from GUI and code.
goatmandude20

C# Host key does not match configured key fingerprint

After reading through the WinSCP .NET docs on SSH keys I need some help. I imported the site from a file and can successfully login via the winscp.exe UI. I verified on the server and protocol information form that I am using the correct fingerprint.
Valid fingerprint (copied directly from WinSCP UI):
ssh-rsa 2048 4d+341...
or
ssh-rsa 2048 7b:e4:e2...

Error Messages:
Host key does not match configured key fingerprint "ssh-rsa 2048 7b:e4:e2..."!
Host key fingerprint is ssh-rsa 2048 KWrXZJFJPrG2J37NoVUvsyu/YGuAfwSNzBDz+qZROqY=

Host key does not match configured key fingerprint "ssh-rsa 2048 4d+341..."!
Host key fingerprint is ssh-rsa 2048 KWrXZJFJPrG2J37NoVUvsyu/YGuAfwSNzBDz+qZROqY=

When I try to use the fingerprint the error message suggest it revokes my key...I used the instructions at this link to clear everything and start over: https://winscp.net/eng/docs/ui_cleanup
I could not find anything in the registry or appdata folders that would be caching the "key fingerprint" in the error message.

Below is the C# code for the session options. All values are passed in from an XML config file and are valid. The only issue is with the fingerprint...

C# Code
SessionOptions sessionOptions = new SessionOptions()
{
    Protocol = Protocol.Sftp,
    HostName = hostName,
    UserName = userName,               
    SshPrivateKeyPath = SshPrivateKeyPath,
    PrivateKeyPassphrase = password,                               
    SshHostKeyFingerprint = sshHostKeyFingerPrint,
    PortNumber = 22
};

How do I overcome this mismatch? Thanks,