Feat: Implement SSH Host Key verification#1579
Open
phantompatch wants to merge 1 commit into
Open
Conversation
jsvk
added a commit
to jsvk/MaterialFiles
that referenced
this pull request
Jul 7, 2026
Squash-merge of upstream PR zhanghai#1579. Adds a HostKeyVerifier implementation so SFTP connections verify host keys after first use, protecting against man-in-the-middle attacks. Introduces SftpHostKeyChangedDialog* so users can explicitly confirm when a host key has changed. Fixes upstream issue zhanghai#544. Original work by phantompatch (https://github.com/phantompatch). Co-authored-by: phantompatch <289516701+phantompatch@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, accessing an SFTP server through Material Files leaves users vulnerable to man-in-the-middle attacks, since the app does not verify Host Keys after the first use.
This PR introduces a class that implements SSHJ's
HostKeyVerifier. It extendsSftpServerAuthenticatorto also handle Host Keys, and adds aSftpHostKeyChangedDialog*so users can explicitly confirm when a Host Key has changed.All changes are kept as simple as possible and try to follow the existing code style closely.
Fixes #544.
I understand that the project maintainer prefers not to accept Pull Requests because of copyright concerns. However, I believe these changes are very important, so I felt it was necessary to submit them. If @zhanghai prefers to retain full copyright over Material Files, I would be happy to release my changes into the public domain.
Please feel free to adjust this code to your liking. I am also open to change requests.
This PR made use of LLM assistance.