Skip to content

Offer every default key, not just the first - #15

Merged
ralyodio merged 1 commit into
mainfrom
fix/offer-every-default-key
Aug 30, 2026
Merged

Offer every default key, not just the first#15
ralyodio merged 1 commit into
mainfrom
fix/offer-every-default-key

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

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 seed1 from a terminal connects as ubuntu, and the reason DiskPush could not is that it never offered the key that host 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 was shown one key, refused it, and the connection ended — while ssh(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:

=== seed1  ubuntu@seed1.h4kr.com:22  auth=agent
  connect -> [auth] SSH authentication was rejected by seed1.h4kr.com.

After:

=== seed1  ubuntu@seed1.h4kr.com:22  auth=agent
  home: 23 entries

seed2 still lists 51 entries and still resolves data -> /mnt/vdb as 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

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
@ralyodio
ralyodio merged commit 0e62357 into main Aug 30, 2026
4 checks passed
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.

1 participant