Skip to content

Conversation

@lox
Copy link
Owner

@lox lox commented Oct 5, 2025

Summary

Check SSH_CONNECTION instead of SSH_AUTH_SOCK to detect SSH sessions

Problem

The Match exec directive had quote parsing errors, and checking SSH_AUTH_SOCK doesn't work because macOS sets it to a default agent that lacks the necessary keys.

Solution

Use SSH_CONNECTION to detect if we're in an SSH session:

Match host * exec "sh -c 'test -z \"$SSH_CONNECTION\"'"
  IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"

Logic:

  • SSH_CONNECTION is empty → Local machine → Use 1Password
  • SSH_CONNECTION is set → In SSH session → Skip 1Password, use forwarded agent

Behavior

Context SSH_CONNECTION Agent Used
Local machine Empty 1Password ✓
GUI apps Empty 1Password ✓
ssh -A (forwarded) Set Forwarded agent ✓

Fixes #51

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

@lox lox force-pushed the fix-ssh-match-exec-escaping branch from bc7488b to 1bc283a Compare October 5, 2025 10:05
Check SSH_CONNECTION instead of SSH_AUTH_SOCK to determine if we're in an
SSH session. This handles the case where SSH_AUTH_SOCK is set to a system
agent that doesn't have the needed keys.

Logic:
- SSH_CONNECTION empty (local machine) → Use 1Password IdentityAgent
- SSH_CONNECTION set (SSH session) → Skip IdentityAgent, use forwarded agent

Match host * exec "sh -c 'test -z \"$SSH_CONNECTION\"'"
  IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"

This ensures:
- Local sessions always use 1Password
- ssh -A properly uses forwarded agent
- GUI apps use 1Password
@lox lox force-pushed the fix-ssh-match-exec-escaping branch from 1bc283a to 2c04d6e Compare October 5, 2025 10:37
@lox lox merged commit 8f2d705 into main Oct 5, 2025
1 check passed
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