Skip to content

Add SSH Agent (gcr-ssh-agent) as an optional service install - #9399

Merged
dhh merged 3 commits into
omacom:quattrofrom
carletex:add-gcr-ssh-agent-service
Sep 28, 2026
Merged

dhh merged 3 commits into
omacom:quattrofrom
carletex:add-gcr-ssh-agent-service

Conversation

@carletex

@carletex carletex commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

This PR is the optional service installation for everyone who doesn't run 1Password (or Bitwarden) as their SSH agent.

Out of the box, a passphrase-protected SSH key only works in an interactive terminal: anything without one (IDEs, coding agents, GUI apps) has nowhere to ask for the passphrase, so SSH pushes just fail. #1661 proposed adding ssh-agent for this, and @dhh's take was:

I use 1password as my ssh agent, so this wouldn't be a good fit for a default setup, but I'm open to the idea that we could have a way to add this on as an optional service installation.

Unlike #1661, which wires up plain ssh-agent, this uses gcr-ssh-agent (already installed on every Omarchy machine via gnome-keyring) which can prompt graphically from any context and needs no ~/.ssh/config changes

What it does

Setup > Security > SSH Agent enables gcr-ssh-agent and points SSH_AUTH_SOCK at it via environment.d. On first use of a key, a dialog prompts for the passphrase:

screenshot-2026-08-31_18-41-56

The key stays unlocked in the agent for the rest of the session. The checkbox is opt-in: nothing is persisted unless the user chooses to remember the passphrase in the keyring (which unlocks at login). A matching Remove > Service entry undoes everything.

Testing

install/remove round-trips, menu show/hide conditions, and end-to-end ssh -T [email protected] from a context with no terminal attached. test/cli passes.

Enables gcr-ssh-agent (already shipped via the gnome-keyring dependency)
so passphrase-protected SSH keys work from any context: the agent prompts
graphically on first use, with opt-in passphrase storage in the keyring.
Adds install/remove commands and Install > Service / Remove > Service
menu entries.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BReZWvvLsDRUaqgjiRzvZ5
@seanpk

seanpk commented Aug 31, 2026

Copy link
Copy Markdown

I arrived here because I have been fighting my agents all day about pushing with my key that has a passphrase. This is the solution we would have invented (and probably have to implement manually until this releases). I sure hope this merges.

@seanpk seanpk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, and assuming that it won't be mergeable without a maintainer approving it, I approve.

The socket's ExecStartPost exports SSH_AUTH_SOCK into the user manager with set-environment, which disabling the socket does not undo, so apps launched after removal still pointed at a stopped agent. The environment.d file also has to be deleted before disable reloads the manager, or the generator re-exports it. Only an SSH_AUTH_SOCK pointing at gcr is cleared, so another agent's stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at c33cb3b. The service does what the description says; one defect in removal is fixed on the branch, and three things are left for the maintainer below.

What was run. On a fresh Omarchy VM, with this branch merged onto current quattro:

  • Installing enabled the socket and wrote the environment.d file, and the menu guards flipped as intended. After a reboot, Hyprland, the shell and apps launched through the user manager all had SSH_AUTH_SOCK=/run/user/1000/gcr/ssh.
  • ssh to a passphrase-protected ed25519 key, run from a process with no terminal, opened the gcr dialog. Unlocking it let the connection through, and four parallel connections afterwards used the unlocked key with no prompt.
  • ./test/cli and ./test/shell show only the failures quattro itself shows on the same VM: the vscode theme, ascii, branding animation, both kernel-header migration and passwordless-grant tests, and runtime-smoke, which fails about one run in five on quattro too.

Pushed: c33cb3b, removal now clears the agent from the session. The socket unit's ExecStartPost exports SSH_AUTH_SOCK into the user manager with set-environment, and disabling the socket does not undo that. After removal, apps launched in that session still pointed at the stopped agent (ssh-add -l: Connection refused) until the user manager restarted. The environment.d file also has to be deleted before disable reloads the manager, or the environment generator exports it again. The remove script now deletes the file first, then clears SSH_AUTH_SOCK only when it still points at gcr, so another agent's setting is left alone. test/shell.d/ssh-agent-service-remove-test.sh covers both cases. It fails against the original script, and against either half of the fix alone.

Found, not changed:

  1. gcr-ssh-agent crashes when a second request arrives while the passphrase dialog is open. On gcr 4.4.0.1 this reproduced three times out of three: the agent logs couldn't prompt for password: Another prompt is already in progress and then segfaults. systemd restarts it, and both requests fail. The gcr 4.4.1 release notes list no fix for it. It only happens before the key is unlocked, but parallel git from an IDE or a coding agent is exactly the use case here. This is an upstream bug; I'm raising it so the maintainer knows before shipping.
  2. "Automatically unlock this key whenever I'm logged in" stores the passphrase in plaintext on a default Omarchy install. gcr saves it through the Secret Service into the default collection (secret_password_storev with a NULL collection in gcr 4.4.1). Omarchy creates that keyring without a password (install/user/default-keyring.sh). A probe secret stored the same way showed up as secret=<value> in ~/.local/share/keyrings/Default_keyring.keyring, so only disk encryption protects it. The install message recommends that option without saying so, and the description calls the keyring one "which unlocks at login". Whether to warn about this is the maintainer's call.
  3. The environment.d file isn't needed. With only the socket enabled and no file, the value reached Hyprland, the shell and launched apps after a reboot, because the socket exports it before the session starts. Without the file, install would be one systemctl line and removal simpler. I left it in: it's a design choice, and it does no harm now that removal clears it.

Second opinion: Codex at medium effort, three rounds. Round one raised the removal defect and the plaintext keyring, and both held up when checked on the VM. Round two, on the fix, suggested grep -F so the runtime path is matched literally rather than as a regex; that is applied. Round three found nothing. Codex can read this review's working notes, so its agreement isn't fully independent; the findings it raised stand on their own.

Waiting on: the maintainer, to decide whether to take the service and whether the keyring point needs a warning. Nothing is needed from the author.

@omarchybot omarchybot added enhancement New feature or request verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Sep 27, 2026
Turning on an SSH agent is security configuration of the machine rather than installing software, so it sits with SSHD and the other Setup > Security entries. It hides once enabled, as Sudoless Docker does, and Remove > Service > SSH Agent turns it back off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Sep 28, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Moved at the maintainer's request: SSH Agent setup now lives under Setup > Security > SSH Agent instead of Install > Service. Turning on an agent configures how the machine handles your keys. Nothing gets installed, since gcr-ssh-agent already ships with gnome-keyring, so it belongs next to SSHD.

Pushed: f14b934

  • bin/omarchy-install-service-ssh-agent is renamed to bin/omarchy-setup-security-ssh-agent, and its contents are unchanged. It now routes as omarchy setup security ssh agent and is listed under the existing setup group.
  • install.service.ssh-agent is replaced by setup.security.ssh-agent, which sits right after SSHD. It hides once the socket is enabled (when: ! systemctl --user -q is-enabled gcr-ssh-agent.socket), the same way Sudoless Docker does in Setup > Security. Setup rows don't use the Install catalog's dimmed disabled style.
  • Remove > Service > SSH Agent and its script stay as they were, since the request only covered where setup lives.

Checked on a worker built from the Omarchy ISO, with this head merged onto current quattro and the shell linked to that tree:

  • Setup > Security lists Fido2, SSHD, SSH Agent, Passwordless Sudo and Sudoless Docker. Install > Service no longer lists SSH Agent.
  • Choosing SSH Agent from the menu with the keyboard ran the setup in the floating terminal. Afterwards gcr-ssh-agent.socket was enabled and active, ~/.config/environment.d/90-gcr-ssh-agent.conf had been written, and /run/user/1000/gcr/ssh existed. The row then dropped out of Setup > Security, and Remove > Service showed SSH Agent.
  • ./test/cli passes except for vscode generated theme references current theme file. Plain quattro fails that same test on the same worker. menu-test.sh (127), menu-guards-test.sh (18) and ssh-agent-service-remove-test.sh (2) all pass.
  • The earlier findings about gcr itself (the crash on concurrent prompts, and where a remembered passphrase is stored) were not re-examined here. The move doesn't touch them.

Second opinion (Codex Medium): found no defects in the move. It could not find any remaining reference to the old command name or menu id. It confirmed that the negated when guard survives the menu's batched guard evaluation, and that the renamed command lists and routes correctly. Its one note was that no automated test pins the row's placement. That placement is what the worker run above checked by hand. It read this session's notes, so its agreement is not guaranteed independent.

verified and ready came off because the head moved. This now waits on the maintainer.

@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge and removed ready Good to merge labels Sep 28, 2026
@dhh
dhh merged commit 324f0ba into omacom:quattro Sep 28, 2026
sgruendel pushed a commit to sgruendel/omarchy that referenced this pull request Oct 3, 2026
…9399)

* Add SSH Agent as an optional service install

Enables gcr-ssh-agent (already shipped via the gnome-keyring dependency)
so passphrase-protected SSH keys work from any context: the agent prompts
graphically on first use, with opt-in passphrase storage in the keyring.
Adds install/remove commands and Install > Service / Remove > Service
menu entries.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BReZWvvLsDRUaqgjiRzvZ5

* Clear the agent's SSH_AUTH_SOCK when removing the SSH agent service

The socket's ExecStartPost exports SSH_AUTH_SOCK into the user manager with set-environment, which disabling the socket does not undo, so apps launched after removal still pointed at a stopped agent. The environment.d file also has to be deleted before disable reloads the manager, or the generator re-exports it. Only an SSH_AUTH_SOCK pointing at gcr is cleared, so another agent's stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Move SSH Agent setup to Setup > Security

Turning on an SSH agent is security configuration of the machine rather than installing software, so it sits with SSHD and the other Setup > Security entries. It hides once enabled, as Sudoless Docker does, and Remove > Service > SSH Agent turns it back off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: David Heinemeier Hansson <[email protected]>
@emirb emirb added this to the 4.5 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants