sshnet / sshnet/SSH.NET

Incorrect and confusing DisconnectReason thrown for host key validation failure

Open
#870 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

When host key fingerprint does not match, the error message in the exception thrown should be more precise like - untrustworthy host key, host key fingerprint validation failed instead of the current confusing message.

The DisconnectReason used here is also not unique - KeyExchangeFailed which is thrown for various other exceptions as well. The user of this SDK cannot distinguish to get the exact error reason.
So, we should be using the correct enum HostKeyNotVerifiable (which is not being used today).
https://github.com/sshnet/SSH.NET/blob/develop/src/Renci.SshNet/Messages/Transport/DisconnectReason.cs#L47

Also please localize the error messages. Hardcoding them is not a good idea

@drieseng

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/Renci.SshNet/Messages/Transport/DisconnectReason.cs and trace the host key fingerprint validation path that currently reports KeyExchangeFailed. Confirm where the precise localized message is produced, then verify that HostKeyNotVerifiable is used and that the resulting error distinguishes this failure from other key-exchange errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.