1
1
mirror of https://github.com/ryantm/agenix.git synced 2024-09-11 06:05:38 +03:00

fix: if an identity is specified, don't use the default ones

fixes #151
This commit is contained in:
Ryan Mulligan 2023-02-18 11:55:58 -08:00
parent e4f0dcc8d3
commit ec396f7a76

View File

@ -107,12 +107,14 @@ function edit {
if [ -f "$FILE" ]
then
DECRYPT=("${DEFAULT_DECRYPT[@]}")
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."
exit 1