You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotfiles/bin/agent.sh

19 lines
499 B
Bash

#!/usr/bin/env bash
# makes sure agent is active and adds keys
if [ -z $SSH_AGENT_SOCK ] ; then
# agent unset
eval $(ssh-agent -s)
if [ "$(ssh-add -l)" = "The agent has no identities." ] ; then
if [ -e ~/.ssh/id_ed25519 ] ; then
ssh-add ~/.ssh/id_ed25519
else
kill $SSH_AGENT_PID
echo -e "No ed25519 keys found! Killing $SSH_AGENT_PID!"
fi
else
kill $SSH_AGENT_PID
echo "Killing $SSH_AGENT_PID!"
fi
fi