Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(devbox): use openssh alias for devbox:ssh (#59495)

Raúl Negrón-Otero5009c83a201e
diff --git a/tools/hogli-commands/hogli_commands/devbox/coder.py b/tools/hogli-commands/hogli_commands/devbox/coder.py
index 9a3b986de49a..411fadf36367 100644
--- a/tools/hogli-commands/hogli_commands/devbox/coder.py
+++ b/tools/hogli-commands/hogli_commands/devbox/coder.py
@@ -1217,9 +1217,20 @@ def user_secret_exists(name: str) -> bool:
return any(isinstance(s, dict) and s.get("name") == name for s in secrets)
+def _ssh_host_alias(name: str) -> str:
+ """Return the ``Host`` alias written by ``coder config-ssh`` for the given workspace."""
+ return f"coder.{name}"
+
+
def ssh_replace(name: str) -> None:
- """SSH into a workspace and replace the current process."""
- _run_or_exit(["coder", "ssh", name])
+ """SSH via the ``coder.*`` host alias so ``~/.ssh/config`` applies.
+
+ Calling ``coder ssh`` directly bypasses the user's ssh config, breaking
+ ``IdentityAgent`` forwarding (Secretive, 1Password) used for commit signing.
+ The wildcard ``Host coder.*`` block written by ``coder config-ssh`` keeps
+ the Coder tunnel via its ``ProxyCommand``.
+ """
+ os.execvp("ssh", ["ssh", _ssh_host_alias(name)])
def port_forward_replace(name: str, local_port: int, remote_port: int) -> None:
@@ -1291,8 +1302,7 @@ def open_cursor(name: str) -> None:
cursor = shutil.which("cursor")
if not cursor:
_fail("`cursor` CLI is not on PATH. Open Cursor and enable Shell Integration from the Command Palette.")
- ssh_host = f"coder.{name}"
- os.execvp(cursor, ["cursor", "--remote", f"ssh-remote+{ssh_host}", "/home/coder/posthog"])
+ os.execvp(cursor, ["cursor", "--remote", f"ssh-remote+{_ssh_host_alias(name)}", "/home/coder/posthog"])
def open_web_ide(name: str) -> None:
diff --git a/tools/hogli-commands/hogli_commands/tests/test_devbox.py b/tools/hogli-commands/hogli_commands/tests/test_devbox.py
index 1bc346ffcd14..9647d14617db 100644
--- a/tools/hogli-commands/hogli_commands/tests/test_devbox.py
+++ b/tools/hogli-commands/hogli_commands/tests/test_devbox.py
@@ -2607,6 +2607,22 @@ class TestEncodeSshOption:
assert next(csv.reader([encoded]))[0] == "ProxyCommand a,b"
+class TestSshReplace:
+ """Verify devbox:ssh routes through the OpenSSH alias, not ``coder ssh``."""
+
+ def test_host_alias_matches_coder_config_ssh_default(self) -> None:
+ # `coder config-ssh` writes `Host coder.*` by default; the alias must match.
+ assert coder._ssh_host_alias("devbox-foo") == "coder.devbox-foo"
+
+ def test_execs_ssh_with_coder_host_alias(self, monkeypatch: pytest.MonkeyPatch) -> None:
+ captured: list[tuple[str, list[str]]] = []
+ monkeypatch.setattr(coder.os, "execvp", lambda file, args: captured.append((file, args)))
+
+ coder.ssh_replace("devbox-foo")
+
+ assert captured == [("ssh", ["ssh", coder._ssh_host_alias("devbox-foo")])]
+
+
class TestSetupGitSigning:
"""Test the Git commit signing step in devbox:setup.