Globally set environment variables for gpg-agent in MacOS High Sierra

2

I want to use gpg-agent instead of ssh-agent in MacOS High Sierra. To achieve this I need to set globally two environment variables:

GPG_TTY=$(tty)
SSH_AUTH_SOCK=${HOME}/.gnupg/S.gpg-agent.ssh

This is required in order to store the passphrases for gpg-authentication keys AND for my ssh keys.

I want this kind of setup in order to use KeePassXC with it's ssh-agent integration feature, so all the random passphrases for my ssh keys are stored there and will be added to gpg-agent (instead of ssh-agent) when KeePassXC database is unlocked. On the other hand the passphrases for my gpg authentication keys will be stored natively in gpg-agent.

Does anyone know how can I globally set up env vars? If I set up them user-wide in my ~/.zshrc, then KeepassXC still starts ssh-agent in parallel with gpg-agent, and adds them to system's ssh-agent instead of gpg-agent.

The end goal is to completely disable ssh-agent, making sure that KeePassXC will not start it, but will use the gpg-agent instead.

I have tried to set env variables with launchctl setenv:

$ launchctl setenv SSH_AUTH_SOCK ${HOME}/.gnupg/S.gpg-agent.ssh
$ launchctl getenv SSH_AUTH_SOCK
/Users/drew/.gnupg/S.gpg-agent.ssh

Looks good, but then:

$ echo $SSH_AUTH_SOCK
/private/tmp/com.apple.launchd.IjNASGcnxM/Listeners

So it seems like the variable set with launchd is ignored...

Drew

Posted 2018-06-06T04:42:44.367

Reputation: 1 628

Try to export those variables: export GPG_TTY and export SSH_AUTH_SOCK – pldg – 2019-01-22T12:05:12.283

No answers