mkdir -p ~/.config && touch ~/.config/ssh-agent.pid- Paste the contents of
ssh-agent-manage.shinto your.bashrcor.bash_profileor 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.socketas the socket, rather than a random-named temporary socket - Tracking the PID of
ssh-agentin~/.config/ssh-agent.pid - setting up the appropriate environment variables to point to any already-running
ssh-agentstarted this way (NB: if you start an agent process by hand, this won't know about it) - starting up an
ssh-agentif it can't find a properly-configured version already running
Thank you for your comment. I didn't know
-Awas 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.