git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/.bash
diff options
context:
space:
mode:
authormail_redacted_for_web 2022-07-06 09:30:28 +0200
committermail_redacted_for_web 2022-07-06 09:30:28 +0200
commit8bf3be857b622fcbe6c49933a3ee7379b514aef1 (patch)
tree47f862235b199f298234cfa79e2886ef6c029dd0 /.bash
parentc079713f467eea6edaa3ad3e658774e40666644c (diff)
downloaddotfiles-8bf3be857b622fcbe6c49933a3ee7379b514aef1.tar.bz2
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.
Diffstat (limited to '.bash')
-rw-r--r--.bash/aliases.bash5
1 files changed, 4 insertions, 1 deletions
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 ----- #