Help and docs
Sign in

grindlemire/dotfiles code browser

nvim 18f6679
29 lines · 882 B
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# This script will ensure that the ssh signing key is loaded into a running agent

# Check if ssh-agent is running
if [ -n "$SSH_AUTH_SOCK" ] && [ -n "$SSH_AGENT_PID" ] && $(ps aux | grep -q $SSH_AGENT_PID) ; then
    echo "ssh-agent is already running"
    ssh-add -l | grep -q "$(ssh-keygen -lf ~/.ssh/signing_key_rsa.pub | awk '{print $2}')"
    if [ $? -eq 0 ]; then
        echo "signing_key_rsa is already added to the agent"
        return 0
    fi
    # Add the signing key to the agents
    echo "adding signing_key_rsa to the agent"
    ssh-add ~/.ssh/signing_key_rsa
    return 0
fi

killall ssh-agent > /dev/null 2>&1 || true
unset SSH_AUTH_SOCK
unset SSH_AGENT_PID

# Start ssh-agent if it's not already running
eval `ssh-agent -s`
echo "ssh-agent started"

# Add the signing key to the agent
echo "adding signing_key_rsa to the agent"
ssh-add ~/.ssh/signing_key_rsa