From 3991e6a781a1cb80b7f8d61f6ecd5fc5d56164a5 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 14 Aug 2017 15:17:09 +0200 Subject: [PATCH] Search for fingerprint instead of key name Signed-off-by: Knut Ahlers --- bin/vault-sshadd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/vault-sshadd b/bin/vault-sshadd index daeee3a..35ae771 100755 --- a/bin/vault-sshadd +++ b/bin/vault-sshadd @@ -39,8 +39,10 @@ vault read -field=private "/secret/ssh-key/\$1" | exec ssh-add -t 3600 - EOF for KEY_NAME in $@; do + fingerprint=$(vault read -field=public "/secret/ssh-key/$1" | ssh-keygen -l -f -) + # If this key is already in the agent we don't need to do anything - if ( ssh-add -l | grep -q "${KEY_NAME}" ); then + if ( ssh-add -l | grep -q "${fingerprint}" ); then info "[${KEY_NAME}] Key already present." continue fi