Offer every default key, not just the first - #15
Merged
Conversation
seed1 rejected DiskPush while `ssh seed1` from a terminal connected as
ubuntu. The host was not refusing our keys, as this was first reported to
the user: it was never offered the one it accepts.
ssh -i ~/.ssh/id_ed25519 seed1 -> Permission denied (publickey,password)
ssh -i ~/.ssh/id_rsa seed1 -> RSA OK
The default-key fallback added in 0.2.5 took the first identity that
exists, and ssh2's `privateKey` holds exactly one. On a machine with both
keys that is always id_ed25519, so a host accepting only id_rsa saw one
key, refused it, and the connection ended — while ssh(1), which offers
each identity in turn, walked straight in.
Agent authentication now hands ssh2 an ordered authHandler: the agent
first when one is found, then every default identity that exists, in
ssh's order. That is what "the way ssh does it" was supposed to mean.
Verified against the host that reported it. Before: `[auth] SSH
authentication was rejected by seed1.h4kr.com`. After: seed1 lists its
home directory, 23 entries. seed2 still lists 51 and still resolves
`data -> /mnt/vdb` as a directory. 4 new tests.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTQ3RzTAey9nT6r1kbGBCd
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.
seed1 was my bug, not the host's
Reported as "still can't connect to seed1", after I had told the user it was the host refusing our credentials. It was not.
ssh seed1from a terminal connects asubuntu, and the reason DiskPush could not is that it never offered the key that host accepts:The default-key fallback added in 0.2.5 took the first identity that exists, and ssh2's
privateKeyholds exactly one. On a machine with both keys that is alwaysid_ed25519, so a host accepting onlyid_rsawas shown one key, refused it, and the connection ended — whilessh(1), which offers each identity in turn, walked straight in.The fix
Agent authentication now hands ssh2 an ordered
authHandler: the agent first when one is found, then every default identity that exists, in ssh's order (id_ed25519,id_ecdsa,id_rsa,id_dsa). ssh2 tries them in sequence, which is what "the way ssh does it" was supposed to mean in the first place.An explicitly configured key path is untouched — that is a deliberate choice by the user and stays a single key.
Verified against the host that reported it
Before:
After:
seed2still lists 51 entries and still resolvesdata -> /mnt/vdbas a directory, so the 0.2.6 symlink work is intact.pnpm test— 327 passed (4 new)pnpm typecheck— clean🤖 Generated with Claude Code
https://claude.ai/code/session_01GTQ3RzTAey9nT6r1kbGBCd