[bin] Fix load_keys script
This commit is contained in:
@ -17,11 +17,12 @@ if [[ ! -d "$ABS_BASE_PATH" ]]; then
|
||||
fi
|
||||
|
||||
# Loop through each identity subdirectory
|
||||
echo -n "Injecting ssh keys "
|
||||
while IFS= read -r dir; do
|
||||
IDENTITY=$(basename "$dir")
|
||||
|
||||
# Find the latest .gpg file by name (ISO sort)
|
||||
LATEST_FILE=$(find "$dir" -maxdepth 1 -name "*.gpg" -printf "%f\n" \
|
||||
LATEST_FILE=$(find "$dir" -maxdepth 1 -name "*.gpg" -exec basename {} \; \
|
||||
| sed 's/\.gpg$//' \
|
||||
| sort -r \
|
||||
| head -n 1)
|
||||
@ -30,12 +31,10 @@ while IFS= read -r dir; do
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Injecting $IDENTITY ($LATEST_FILE) into ssh-agent..."
|
||||
echo -n "."
|
||||
|
||||
# Decrypt and pipe directly to ssh-add
|
||||
# The '-' tells ssh-add to read the key from standard input (stdin)
|
||||
pass show "${PASS_BASE}/${IDENTITY}/${LATEST_FILE}" | ssh-add - >/dev/null 2>&1
|
||||
|
||||
done < <(find "$ABS_BASE_PATH" -mindepth 1 -maxdepth 1 -type d)
|
||||
|
||||
echo "Done. All latest keys injected into agent."
|
||||
|
||||
Reference in New Issue
Block a user