Felix Hanley

Starting SSH agent

2025-03-16 ssh

So there is a thread on SO and there are a bunch of tools to do it.

This seems to work for now in my .profile:

ssh-agent -u >/dev/null
if [ ! -S $HOME/.ssh/ssh_auth_sock ]; then
    eval $(ssh-agent)
    ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock"
ssh-add -l >/dev/null || ssh-add

The trick is cleaning up the old stuff properly.