mkdir -p ~/.config && touch ~/.config/ssh-agent.pid
- Paste the contents of
ssh-agent-manage.sh
into your.bashrc
or.bash_profile
or similar killall -9 ssh-agent
- Start a new terminal session (note: old sessions will not see ssh-agent, only new ones)
This snippet, when included in .bashrc
, will ensure that your session has a working ssh-agent
with all your ssh keys loaded into it. It does this without creating separate ssh-agent
processes by:
- Using
~/.config/ssh-agent.socket
as the socket, rather than a random-named temporary socket - Tracking the PID of
ssh-agent
in~/.config/ssh-agent.pid
- setting up the appropriate environment variables to point to any already-running
ssh-agent
started this way (NB: if you start an agent process by hand, this won't know about it) - starting up an
ssh-agent
if it can't find a properly-configured version already running
Thank you for your comment. I didn't know
-A
was deprecated on MacOS, because I don't use it. But I do know it is removed (not deprecated) on my WSL Debian (unstable) although I don't know when.I did a workaround with simple bash script to traverse the directory to add all keys.