Skip to content

The agent that grows with you

fix(update): diagnose SSH publickey / host-key fetch failures

brooklyn!db114c250480
diff --git a/hermes_cli/update_cmd_git.py b/hermes_cli/update_cmd_git.py
index fa1f0f9e194..16e7714c54f 100644
--- a/hermes_cli/update_cmd_git.py
+++ b/hermes_cli/update_cmd_git.py
@@ -345,6 +345,14 @@ _FETCH_FAILURE_RULES = (
" `git remote -v` points at a public repo."),
(lambda s: "Authentication failed" in s,
"✗ Authentication failed — check your git credentials or SSH key."),
+ # SSH auth failures never say "Authentication failed" — OpenSSH prints its own
+ # "Permission denied (publickey)"/"Host key verification failed" and git wraps
+ # it as "Could not read from remote repository", which otherwise fell through
+ # to the generic message below and left an SSH-remote user with no idea their
+ # key (or lack of one) was the cause (#82169).
+ (lambda s: "Permission denied (publickey)" in s or "Host key verification failed" in s,
+ "✗ SSH authentication failed — check your SSH key is added to GitHub, or switch"
+ " `origin` to HTTPS: `git remote set-url origin https://github.com/NousResearch/hermes-agent.git`."),
)
diff --git a/tests/hermes_cli/test_update_fetch_failure_classifier.py b/tests/hermes_cli/test_update_fetch_failure_classifier.py
index aeb9c67e3e7..1c5297a84bc 100644
--- a/tests/hermes_cli/test_update_fetch_failure_classifier.py
+++ b/tests/hermes_cli/test_update_fetch_failure_classifier.py
@@ -67,6 +67,25 @@ class TestClassifyFetchFailure:
)
assert "Authentication failed" in msg
+ def test_ssh_publickey_denial_reports_ssh_auth_not_generic(self):
+ # git wraps OpenSSH's own rejection as "Could not read from remote
+ # repository" — never "Authentication failed" — so this needs its
+ # own rule ahead of the generic fallback (#82169).
+ msg = update_cmd._classify_fetch_failure(
+ "[email protected]: Permission denied (publickey).\n"
+ "fatal: Could not read from remote repository."
+ )
+ assert "SSH authentication failed" in msg
+ assert "https://github.com/NousResearch/hermes-agent.git" in msg
+
+ def test_ssh_host_key_failure_reports_ssh_auth(self):
+ msg = update_cmd._classify_fetch_failure(
+ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
+ "Host key verification failed.\n"
+ "fatal: Could not read from remote repository."
+ )
+ assert "SSH authentication failed" in msg
+
def test_unknown_falls_back_to_generic(self):
msg = update_cmd._classify_fetch_failure("fatal: something novel")
assert msg == "✗ Failed to fetch updates from origin."