aliquote

< a quantity that can be divided into another a whole number of time />

August 30, 2022

TIL that I no longer need to worry with launching ssh-agent automagically in case it isn’t already running in the background using the following hack:

if [ -f ~/.ssh/agent.env ] ; then
    . ~/.ssh/agent.env > /dev/null
    if ! kill -0 $SSH_AGENT_PID > /dev/null 2>&1; then
        echo "Stale agent file found. Spawning a new agent. "
        eval `ssh-agent | tee ~/.ssh/agent.env`
        ssh-add
    fi
else
    echo "Starting ssh-agent"
    eval `ssh-agent | tee ~/.ssh/agent.env`
    ssh-add
fi

There’s probably a better way: Howto: auto-start ssh-agent with systemd on Debian Bullseye.