Skip to content

Instantly share code, notes, and snippets.

@adaam
Last active May 2, 2024 06:39
Show Gist options
  • Save adaam/0957ce8ca1666babd67a0c0d602016be to your computer and use it in GitHub Desktop.
Save adaam/0957ce8ca1666babd67a0c0d602016be to your computer and use it in GitHub Desktop.
Get ssh-agent SSH_AUTH_SOCK
# Search running ssh-agent
# Source: https://github.com/docker/for-mac/issues/6541#issuecomment-1304604625
SSH_AGENT_PID="$(pgrep ssh-agent)"
SSH_AUTH_SOCK="$(lsof -p "${SSH_AGENT_PID}" | awk '/ unix / {print $8}')
export SSH_AGENT_PID SSH_AUTH_SOCK
# Mac will automatic run it when system launch
# Source: https://stackoverflow.com/a/64023733/23585785, https://github.com/docker/for-mac/issues/4242#issuecomment-697197199
export SSH_AUTH_SOCK=`launchctl getenv SSH_AUTH_SOCK`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment