Skip to content

setup: offer the private key, not its .pub, and default to the bot's key - #214

Merged
bbondy merged 1 commit into
masterfrom
setup-pin-private-ssh-key
Nov 8, 2026
Merged

bbondy merged 1 commit into
masterfrom
setup-pin-private-ssh-key

Conversation

@netzenbot

Copy link
Copy Markdown
Collaborator

User impact: make setup now pins a key the scheduled runs can push with, so cron jobs stop dying at git fetch origin.

The problem

make setup offered an unencrypted key pair as its .pub and defaulted the SSH prompt to 0 (no pinning). A .pub only authenticates through ssh-agent, and cron has none. Choosing it pinned core.sshCommand to the .pub, so every cron chain failed at git fetch origin and the scheduled runs and review jobs stopped. Pressing Enter at the prompt left bot.sshKeyPath null, which cron cannot push with either.

Reproduce

  1. Have ~/.ssh/netzenbot (no passphrase) and ~/.ssh/netzenbot.pub.
  2. Run make setup and press Enter at "Select the key the bot pushes with": sshKeyPath is saved as null.
  3. Run make setup again and pick the listed key: it is netzenbot.pub, and core.sshCommand becomes ssh -o IdentitiesOnly=yes -i ~/.ssh/netzenbot.pub.
  4. With no agent: env -i HOME=$HOME PATH=/usr/bin:/bin git ls-remote origin HEAD prints Load key ".../netzenbot.pub": error in libcrypto and Permission denied (publickey). Expected: the commit hash.

The test added goes last: test_unencrypted_pair_is_offered_as_the_private_key.

The fix

A key pair is listed as its .pub only when the private half is encrypted and needs the agent; an unencrypted pair is listed as the private key. With no earlier choice, the prompt defaults to the first key that GitHub reports as the bot's account instead of 0.

Test plan

  • make check — 1700 passed, 4 skipped
  • env -i ... git ls-remote origin HEAD with core.sshCommand set to the private key — returns the hash
  • CI passes cleanly

make setup listed an unencrypted key pair as its .pub and defaulted the SSH
prompt to 0 (no pinning). A .pub only authenticates through ssh-agent; cron
has none, so core.sshCommand pinned to the .pub failed with "error in
libcrypto" and every cron chain died at `git fetch origin`. Pressing Enter at
the prompt left bot.sshKeyPath null, which cron cannot push with either.

A pair is now offered as its .pub only when the private half is encrypted and
needs the agent. With no earlier choice the prompt defaults to the first key
GitHub reports as the bot's account.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bbondy
bbondy merged commit cc0191f into master Nov 8, 2026
3 checks passed
@bbondy
bbondy deleted the setup-pin-private-ssh-key branch November 8, 2026 23:22
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