Don't import ssh keys repeatedly

This commit is contained in:
Tony Grosinger 2022-11-28 14:19:50 -08:00
parent 61618c431f
commit 81842bf038

10
.bashrc
View File

@ -39,11 +39,13 @@ if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
sed -i '/^echo Agent pid.*/d' $HOME/.ssh/ssh-agent
fi
eval `\cat $HOME/.ssh/ssh-agent`
fi
for key in $(find "${HOME}/.ssh" -type f -name "*.pub"); do
ssh-add -q "${key%.*}"
done
for key in $(find "${HOME}/.ssh" -type f -name "*.pub"); do
# Don't add if a key with this fingerprint is already in the agent.
fp="$(ssh-keygen -lf "${key%.*}" | awk '{print $2}')"
ssh-add -l |grep -q "${fp}" || ssh-add -q "${key%.*}"
done
fi
# bind -x '"\C-r"':reset
fi