Skip to content

fix: let a refused SSH key fall back to the password - #3

Merged
ValgulNecron merged 1 commit into
mainfrom
fix/key-login-falls-back-to-password
Nov 23, 2026
Merged

ValgulNecron merged 1 commit into
mainfrom
fix/key-login-falls-back-to-password

Conversation

@ValgulNecron

Copy link
Copy Markdown
Contributor

Summary

Found live on a real cluster: sftp -P 2222 user@host got "Connection to … closed by remote host" right after the host key, with no password prompt. ssh -vvv showed Authenticated … using "publickey" and the server logged login refused … result=denied.

Cause: PublicKeyCallback accepted every offered key (it runs before the signature check, so it can't ask the API), and the API login ran in establish after 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 share loggedIn (session cap + pending session), and establish only 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 sftp pointer in Gameplane.


Generated by Claude Code

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>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f556216e-acfa-4656-b195-29b37973fc57
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ValgulNecron
ValgulNecron merged commit c5baacf into main Nov 23, 2026
6 checks passed
@ValgulNecron
ValgulNecron deleted the fix/key-login-falls-back-to-password branch November 24, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants