ssh-agent checker

This commit is contained in:
Sonny 2017-07-04 07:00:13 +02:00
parent bc94c36563
commit ad1755938c

View file

@ -1 +1,16 @@
#!/bin/bash
# Start ssh-agent and add keys in ~/.ssh directory
# Should only be used without a desktop manager
ENV=/tmp/.agent_env
KEYS=$(basename --suffix=.pub -a $HOME/.ssh/*.pub)
if [ -z "$SSH_AGENT_PID" ] && [ ! -e "$ENV" ] ; then
ssh-agent > $ENV
source $ENV
for key in $KEYS;
do
ssh-add ~/.ssh/$key
done
echo 'Agent started'
else
source $ENV
echo 'Agent started already, good to go'
fi