0

When I run (getenv "SSH_AUTH_SOCK"), I get "/private/tmp/com.apple.launchd.K9OEFgxDgw/Listeners".

I want to set it to the value that is returned by echo $SSH_AUTH_SOCK on the command line which is something like /tmp/ssh-P7OPvY12nTFk/agent.35299

Unfortunately, (shell-command-to-string "echo $SSH_AUTH_SOCK") also returns "/private/tmp/com.apple.launchd.K9OEFgxDgw/Listeners".

How can I set SSH_AUTH_SOCK to /tmp/ssh-XXXXXXXXX/agent.YYYYY?

The background is that I want Magit to be aware of the SSH agent I'm running so I can connect to Bitbucket repositories.

EDIT: I solved my problem by using the Keychain tool and keychain-environment for Emacs (see this answer by the Magit author).

4
  • I assume this is the GUI vs command line environment thing of macOS? Perhaps github.com/purcell/exec-path-from-shell would help? (The name talks about exec-path, but afaik, it can be used for any environment variable)
    – npostavs
    Commented Jul 18, 2019 at 11:41
  • How and where/when are you running the agent, and are you starting Emacs in that same environment? If not, then obviously it can't inherit environment variables which aren't present at the time.
    – phils
    Commented Jul 18, 2019 at 11:48
  • That said, do you actually need two? Perhaps your real problem is that you're starting a second ssh-agent instead of using an existing one?
    – phils
    Commented Jul 18, 2019 at 11:51
  • I run the agent manually from the command line. I start Emacs as a standard macOS application. Interestingly, when I start emacs with --no-init, (shell-command-to-string "SSH_AUTH_SOCK") picks up the SSH agent socket under /tmp. You're right at in the long term, I should figure out how to add Bitbucket to macOS system agent.
    – malana
    Commented Jul 18, 2019 at 21:56

0

Browse other questions tagged or ask your own question.