From 8bf3be857b622fcbe6c49933a3ee7379b514aef1 Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Wed, 6 Jul 2022 09:30:28 +0200 Subject: Only add SSH key if it's not been added yet. Currently, ```ssh-add -l``` displays the fingerprint the same way ```ssh-keygen -Esha256 -lf``` does. Simple comparison, done. --- .bash/aliases.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.bash/aliases.bash b/.bash/aliases.bash index d104328..c6650e0 100644 --- a/.bash/aliases.bash +++ b/.bash/aliases.bash @@ -73,7 +73,10 @@ alias sshk='ssh -o PasswordAuthentication=yes -o PreferredAuthentications=keyboa alias sshg="ssh-with-gpg" function add-sshagent-init { for KEY in "${SSHKEYS[@]}";do - ssh-add "$KEY" + FFPRINT="$(ssh-keygen -Esha256 -lf "$KEY")" + if ! ssh-add -l 2>/dev/null | grep "$FFPRINT" >/dev/null; then + ssh-add "$KEY" + fi done } # ----- FS ----- # -- cgit v1.2.3