From f0c0f9d69e57e367073d3e532a5f5596d3e28a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez?= Date: Mon, 31 Aug 2026 18:45:56 +0200 Subject: [PATCH 1/3] 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 Claude-Session: https://claude.ai/code/session_01BReZWvvLsDRUaqgjiRzvZ5 --- bin/omarchy-install-service-ssh-agent | 17 +++++++++++++++++ bin/omarchy-remove-service-ssh-agent | 10 ++++++++++ default/omarchy/omarchy-menu.jsonc | 2 ++ 3 files changed, 29 insertions(+) create mode 100755 bin/omarchy-install-service-ssh-agent create mode 100755 bin/omarchy-remove-service-ssh-agent diff --git a/bin/omarchy-install-service-ssh-agent b/bin/omarchy-install-service-ssh-agent new file mode 100755 index 000000000000..0c646f72765e --- /dev/null +++ b/bin/omarchy-install-service-ssh-agent @@ -0,0 +1,17 @@ +#!/bin/bash + +# omarchy:summary=Enable an SSH agent (gcr-ssh-agent) that prompts for key passphrases graphically. + +set -e + +ENV_FILE="$HOME/.config/environment.d/90-gcr-ssh-agent.conf" + +systemctl --user enable --now gcr-ssh-agent.socket + +mkdir -p "$(dirname "$ENV_FILE")" +echo 'SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh' >"$ENV_FILE" + +echo "" +echo "SSH agent has been enabled. Log out and back in to make it available everywhere." +echo "The first use of a passphrase-protected key opens a dialog, with the option to" +echo "remember the passphrase in the keyring." diff --git a/bin/omarchy-remove-service-ssh-agent b/bin/omarchy-remove-service-ssh-agent new file mode 100755 index 000000000000..1fb0ca51b8cc --- /dev/null +++ b/bin/omarchy-remove-service-ssh-agent @@ -0,0 +1,10 @@ +#!/bin/bash + +# omarchy:summary=Disable the gcr-ssh-agent SSH agent and its environment override. + +systemctl --user disable --now gcr-ssh-agent.socket 2>/dev/null || true +systemctl --user stop gcr-ssh-agent.service 2>/dev/null || true +rm -f "$HOME/.config/environment.d/90-gcr-ssh-agent.conf" + +echo "" +echo "SSH agent has been disabled. Log out and back in for it to take full effect." diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index 10a045afba58..eefaf416e77d 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -225,6 +225,7 @@ "install.service.once": {"icon":"󰏖","label":"ONCE","disabled":"omarchy-pkg-present once-bin","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-service-once"}, "install.service.bitwarden": {"icon":"󰟵","label":"Bitwarden","disabled":"omarchy-pkg-present bitwarden","action":"omarchy-install-and-launch Bitwarden 'bitwarden bitwarden-cli' bitwarden"}, "install.service.chromium-account": {"icon":"","label":"Chromium Account","when":"[[ -f ~/.config/chromium-flags.conf ]]","disabled":"grep -q oauth2-client-id ~/.config/chromium-flags.conf","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-chromium-google-account"}, + "install.service.ssh-agent": {"icon":"󰣀","label":"SSH Agent","disabled":"systemctl --user -q is-enabled gcr-ssh-agent.socket","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-service-ssh-agent"}, "install.editor.vscode": {"icon":"","label":"VSCode","disabled":"omarchy-pkg-present visual-studio-code-bin","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-editor-vscode"}, "install.editor.cursor": {"icon":"","label":"Cursor","disabled":"omarchy-pkg-present cursor-bin","action":"omarchy-install-and-launch Cursor cursor-bin cursor"}, "install.editor.zed": {"icon":"","label":"Zed","disabled":"omarchy-pkg-present zed","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-editor-zed"}, @@ -300,6 +301,7 @@ "remove.browser.zen": {"icon":"","label":"Zen","when":"omarchy-pkg-present zen-browser-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-remove-browser zen'"}, "remove.service.dropbox": {"icon":"","label":"Dropbox","when":"omarchy-pkg-present dropbox","action":"omarchy-launch-floating-terminal-with-presentation omarchy-remove-service-dropbox"}, "remove.service.tailscale": {"icon":"","label":"Tailscale","when":"omarchy-pkg-present tailscale","action":"omarchy-launch-floating-terminal-with-presentation omarchy-remove-service-tailscale"}, + "remove.service.ssh-agent": {"icon":"󰣀","label":"SSH Agent","when":"systemctl --user -q is-enabled gcr-ssh-agent.socket","action":"omarchy-launch-floating-terminal-with-presentation omarchy-remove-service-ssh-agent"}, "remove.ai.chatgpt": {"icon":"","iconFont":"omarchy","label":"ChatGPT Desktop","when":"omarchy-pkg-present openai-codex-desktop","action":"omarchy-launch-floating-terminal-with-presentation omarchy-remove-ai-chatgpt"}, "remove.ai.dictation": {"icon":"","label":"Dictation","when":"omarchy-pkg-present voxtype-bin","action":"omarchy-launch-floating-terminal-with-presentation omarchy-voxtype-remove"}, "remove.ai.grok-bot": {"icon":"","iconFont":"omarchy","label":"Grok Bot","when":"omarchy-pkg-present grok-bot","action":"omarchy-launch-floating-terminal-with-presentation omarchy-remove-ai-grok-bot"}, From c33cb3b43a4d205832e7828246b858b190533c3d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 26 Sep 2026 23:47:12 +0200 Subject: [PATCH 2/3] 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 --- bin/omarchy-remove-service-ssh-agent | 8 ++- test/shell.d/ssh-agent-service-remove-test.sh | 54 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100755 test/shell.d/ssh-agent-service-remove-test.sh diff --git a/bin/omarchy-remove-service-ssh-agent b/bin/omarchy-remove-service-ssh-agent index 1fb0ca51b8cc..9201ebf47f46 100755 --- a/bin/omarchy-remove-service-ssh-agent +++ b/bin/omarchy-remove-service-ssh-agent @@ -2,9 +2,15 @@ # omarchy:summary=Disable the gcr-ssh-agent SSH agent and its environment override. +# The file goes before disable reloads the manager, or the environment generator keeps exporting it. +rm -f "$HOME/.config/environment.d/90-gcr-ssh-agent.conf" systemctl --user disable --now gcr-ssh-agent.socket 2>/dev/null || true systemctl --user stop gcr-ssh-agent.service 2>/dev/null || true -rm -f "$HOME/.config/environment.d/90-gcr-ssh-agent.conf" + +# The socket exported SSH_AUTH_SOCK to the user manager, which outlives the agent. +if systemctl --user show-environment | grep -Fqx "SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh"; then + systemctl --user unset-environment SSH_AUTH_SOCK +fi echo "" echo "SSH agent has been disabled. Log out and back in for it to take full effect." diff --git a/test/shell.d/ssh-agent-service-remove-test.sh b/test/shell.d/ssh-agent-service-remove-test.sh new file mode 100755 index 000000000000..ff528eb14cd6 --- /dev/null +++ b/test/shell.d/ssh-agent-service-remove-test.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +mock_bin="$test_tmp/bin" +mkdir -p "$mock_bin" + +# A user manager with systemd's two environment blocks: set-environment's, which +# outlives the socket that wrote it, and the generator's, re-read from +# environment.d on every reload, which disable triggers. +cat >"$mock_bin/systemctl" <<'SH' +#!/bin/bash +state=$OMARCHY_TEST_MANAGER +case $2 in + disable) + if [[ -f $HOME/.config/environment.d/90-gcr-ssh-agent.conf ]]; then + echo "SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh" >"$state/generated" + else + : >"$state/generated" + fi + ;; + unset-environment) : >"$state/explicit" ;; + show-environment) cat "$state/generated" "$state/explicit" ;; +esac +exit 0 +SH +chmod +x "$mock_bin/systemctl" + +run_remove() { + local explicit="$1" + + export HOME="$test_tmp/home" XDG_RUNTIME_DIR="$test_tmp/run" OMARCHY_TEST_MANAGER="$test_tmp/manager" + rm -rf "$HOME" "$OMARCHY_TEST_MANAGER" + mkdir -p "$HOME/.config/environment.d" "$OMARCHY_TEST_MANAGER" + echo 'SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh' >"$HOME/.config/environment.d/90-gcr-ssh-agent.conf" + echo "SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh" >"$OMARCHY_TEST_MANAGER/generated" + echo "$explicit" >"$OMARCHY_TEST_MANAGER/explicit" + + PATH="$mock_bin:$PATH" "$ROOT/bin/omarchy-remove-service-ssh-agent" >/dev/null + PATH="$mock_bin:$PATH" systemctl --user show-environment +} + +env_after=$(run_remove "SSH_AUTH_SOCK=$test_tmp/run/gcr/ssh") +[[ -z $env_after ]] || fail "removal leaves no SSH_AUTH_SOCK pointing at the stopped agent" "$env_after" +pass "removal leaves no SSH_AUTH_SOCK pointing at the stopped agent" + +env_after=$(run_remove "SSH_AUTH_SOCK=$test_tmp/run/other-agent.sock") +[[ $env_after == "SSH_AUTH_SOCK=$test_tmp/run/other-agent.sock" ]] || fail "removal keeps an SSH_AUTH_SOCK another agent set" "$env_after" +pass "removal keeps an SSH_AUTH_SOCK another agent set" From f14b934e64a621ed964f202cf5862f4ce25e77f4 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 28 Sep 2026 07:56:19 +0200 Subject: [PATCH 3/3] 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 --- ...stall-service-ssh-agent => omarchy-setup-security-ssh-agent} | 0 default/omarchy/omarchy-menu.jsonc | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename bin/{omarchy-install-service-ssh-agent => omarchy-setup-security-ssh-agent} (100%) diff --git a/bin/omarchy-install-service-ssh-agent b/bin/omarchy-setup-security-ssh-agent similarity index 100% rename from bin/omarchy-install-service-ssh-agent rename to bin/omarchy-setup-security-ssh-agent diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index eefaf416e77d..0cc22de59b52 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -178,6 +178,7 @@ "setup.security.fingerprint": {"icon":"󰈷","label":"Fingerprint","when":"omarchy-hw-fingerprint","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-fingerprint"}, "setup.security.fido2": {"icon":"","label":"Fido2","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-fido2"}, "setup.security.sshd": {"icon":"󰣀","label":"SSHD","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-sshd"}, + "setup.security.ssh-agent": {"icon":"󰣀","label":"SSH Agent","when":"! systemctl --user -q is-enabled gcr-ssh-agent.socket","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-ssh-agent"}, "setup.security.passwordless-sudo": {"icon":"󰟵","label":"Passwordless Sudo","action":"omarchy-launch-floating-terminal-with-presentation omarchy-sudo-passwordless"}, "setup.security.sudoless-docker": {"icon":"󰡨","label":"Sudoless Docker","when":"omarchy-sudo-docker --configured","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-sudoless-docker"}, "setup.config.hyprland": {"icon":"","label":"Hyprland","action":"omarchy-launch-config-editor \"$HOME/.config/hypr/hyprland.lua\""}, @@ -225,7 +226,6 @@ "install.service.once": {"icon":"󰏖","label":"ONCE","disabled":"omarchy-pkg-present once-bin","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-service-once"}, "install.service.bitwarden": {"icon":"󰟵","label":"Bitwarden","disabled":"omarchy-pkg-present bitwarden","action":"omarchy-install-and-launch Bitwarden 'bitwarden bitwarden-cli' bitwarden"}, "install.service.chromium-account": {"icon":"","label":"Chromium Account","when":"[[ -f ~/.config/chromium-flags.conf ]]","disabled":"grep -q oauth2-client-id ~/.config/chromium-flags.conf","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-chromium-google-account"}, - "install.service.ssh-agent": {"icon":"󰣀","label":"SSH Agent","disabled":"systemctl --user -q is-enabled gcr-ssh-agent.socket","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-service-ssh-agent"}, "install.editor.vscode": {"icon":"","label":"VSCode","disabled":"omarchy-pkg-present visual-studio-code-bin","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-editor-vscode"}, "install.editor.cursor": {"icon":"","label":"Cursor","disabled":"omarchy-pkg-present cursor-bin","action":"omarchy-install-and-launch Cursor cursor-bin cursor"}, "install.editor.zed": {"icon":"","label":"Zed","disabled":"omarchy-pkg-present zed","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-editor-zed"},