In the end I was able to fix the problem by mostly following the article I posted above:
- I created the following directory:
mkdir -p ~/Library/LaunchAgents
- I created a file named
environment.plistin the same directory:
nano ~/Library/LaunchAgents/environment.plist
- I pasted the following XML content into the file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.d$
<plist version="1.0">
<dict>
<key>Label</key>
<string>setenv.SSH_AUTH_SOCK</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>SSH_AUTH_SOCK</string>
<string>/Users/<user>/.bitwarden-ssh-agent.sock</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Remember to replace <user> with your MacOS account username!
- Given that the environment variable wasn’t being set in the terminal I added the following code to my
~/.zshrc:
export SSH_AUTH_SOCK=$(launchctl getenv SSH_AUTH_SOCK)
Hopefully this will be useful to other MacOS users!