Repository navigation
fix: let a refused SSH key fall back to the password - #3
Merged
Merged
Conversation
The SSH layer accepted any offered key and the API was asked only after the handshake, so an unregistered key ended in "connection closed by remote host" and OpenSSH never prompted for the SFTP password. Ask the API in VerifiedPublicKeyCallback instead, after the signature check but still during authentication: a refused key now fails only that attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
Summary
Found live on a real cluster:
sftp -P 2222 user@hostgot "Connection to … closed by remote host" right after the host key, with no password prompt.ssh -vvvshowedAuthenticated … using "publickey"and the server loggedlogin refused … result=denied.Cause:
PublicKeyCallbackaccepted every offered key (it runs before the signature check, so it can't ask the API), and the API login ran inestablishafter the handshake. An unregistered key therefore completed SSH authentication, the API refused it, and the server closed the connection. The client never fell back to the password.Fix: the API login for a key now runs in
VerifiedPublicKeyCallback(x/crypto ≥ v0.3x; the module is on v0.59). It still runs only after the signature is verified, but now during authentication, so a refused key fails just that attempt and the client goes on to its next key or the password. Password and key logins now shareloggedIn(session cap + pending session), andestablishonly reads the session from the permissions.Each refused key costs one failed login at the API, as each wrong password does. Before, the first refused key ended the connection.
Tests
New
internal/sshserver/key_fallback_test.go: an unregistered key followed by a password logs in, and SFTP works. Existing tests unchanged and passing.Shipping
After merge, bump the
sftppointer in Gameplane.Generated by Claude Code