C# Host key does not match configured key fingerprint

Advertisement

goatmandude20
Joined:
Posts:
2
Location:
Utah

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,

Reply with quote

Advertisement

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.

Reply with quote

Advertisement

You can post new topics in this forum