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" ] if [ -f "$FILE" ]
then then
DECRYPT=("${DEFAULT_DECRYPT[@]}") DECRYPT=("${DEFAULT_DECRYPT[@]}")
if [[ "${DECRYPT[*]}" != *"--identity"* ]]; then
if [ -f "$HOME/.ssh/id_rsa" ]; then if [ -f "$HOME/.ssh/id_rsa" ]; then
DECRYPT+=(--identity "$HOME/.ssh/id_rsa") DECRYPT+=(--identity "$HOME/.ssh/id_rsa")
fi fi
if [ -f "$HOME/.ssh/id_ed25519" ]; then if [ -f "$HOME/.ssh/id_ed25519" ]; then
DECRYPT+=(--identity "$HOME/.ssh/id_ed25519") DECRYPT+=(--identity "$HOME/.ssh/id_ed25519")
fi fi
fi
if [[ "${DECRYPT[*]}" != *"--identity"* ]]; then 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." 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 exit 1