From ec396f7a769390228c0e42b7a874e263f88482b8 Mon Sep 17 00:00:00 2001 From: Ryan Mulligan Date: Sat, 18 Feb 2023 11:55:58 -0800 Subject: [PATCH] fix: if an identity is specified, don't use the default ones fixes #151 --- pkgs/agenix.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/agenix.sh b/pkgs/agenix.sh index afbfa4d..7a0f0ff 100644 --- a/pkgs/agenix.sh +++ b/pkgs/agenix.sh @@ -107,11 +107,13 @@ function edit { if [ -f "$FILE" ] then DECRYPT=("${DEFAULT_DECRYPT[@]}") - if [ -f "$HOME/.ssh/id_rsa" ]; then - DECRYPT+=(--identity "$HOME/.ssh/id_rsa") - fi - if [ -f "$HOME/.ssh/id_ed25519" ]; then - DECRYPT+=(--identity "$HOME/.ssh/id_ed25519") + if [[ "${DECRYPT[*]}" != *"--identity"* ]]; then + if [ -f "$HOME/.ssh/id_rsa" ]; then + DECRYPT+=(--identity "$HOME/.ssh/id_rsa") + fi + if [ -f "$HOME/.ssh/id_ed25519" ]; then + DECRYPT+=(--identity "$HOME/.ssh/id_ed25519") + fi fi if [[ "${DECRYPT[*]}" != *"--identity"* ]]; then echo "No identity found to decrypt $FILE. Try adding an SSH key at $HOME/.ssh/id_rsa or $HOME/.ssh/id_ed25519 or using the --identity flag to specify a file."