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
@soundlake -- newer versions of
ssh-add
on macOS have deprecated-A
in favor of--apple-load-keychain
; you can either swap that out or addexport APPLE_SSH_ADD_BEHAVIOR=macos
to your environment