Browse Source

[bin] Fix load_keys script

Colin Powell 5 days ago
parent
commit
b35f68817e
2 changed files with 3 additions and 45 deletions
  1. 3 4
      bin/.bin/load_keys
  2. 0 41
      bin/.bin/load_keys.freebsd

+ 3 - 4
bin/.bin/load_keys

@@ -17,11 +17,12 @@ if [[ ! -d "$ABS_BASE_PATH" ]]; then
 fi
 fi
 
 
 # Loop through each identity subdirectory
 # Loop through each identity subdirectory
+echo -n "Injecting ssh keys "
 while IFS= read -r dir; do
 while IFS= read -r dir; do
   IDENTITY=$(basename "$dir")
   IDENTITY=$(basename "$dir")
   
   
   # Find the latest .gpg file by name (ISO sort)
   # 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$//' \
     | sed 's/\.gpg$//' \
     | sort -r \
     | sort -r \
     | head -n 1)
     | head -n 1)
@@ -30,12 +31,10 @@ while IFS= read -r dir; do
     continue
     continue
   fi
   fi
 
 
-  echo "Injecting $IDENTITY ($LATEST_FILE) into ssh-agent..."
+  echo -n "."
   
   
   # Decrypt and pipe directly to ssh-add
   # Decrypt and pipe directly to ssh-add
   # The '-' tells ssh-add to read the key from standard input (stdin)
   # 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
   pass show "${PASS_BASE}/${IDENTITY}/${LATEST_FILE}" | ssh-add - >/dev/null 2>&1
 
 
 done < <(find "$ABS_BASE_PATH" -mindepth 1 -maxdepth 1 -type d)
 done < <(find "$ABS_BASE_PATH" -mindepth 1 -maxdepth 1 -type d)
-
-echo "Done. All latest keys injected into agent."

+ 0 - 41
bin/.bin/load_keys.freebsd

@@ -1,41 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-PASS_BASE="personal/ssh"
-STORE_ROOT="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
-ABS_BASE_PATH="${STORE_ROOT}/${PASS_BASE}"
-
-# Ensure ssh-agent is running
-if [[ -z "${SSH_AUTH_SOCK:-}" ]]; then
-    eval "$(ssh-agent -s)"
-fi
-
-# Verify the base path exists
-if [[ ! -d "$ABS_BASE_PATH" ]]; then
-  echo "ERROR: Base path not found in pass: $PASS_BASE" >&2
-  exit 1
-fi
-
-# Loop through each identity subdirectory
-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" -exec basename {} \; \
-    | sed 's/\.gpg$//' \
-    | sort -r \
-    | head -n 1)
-
-  if [[ -z "$LATEST_FILE" ]]; then
-    continue
-  fi
-
-  echo "Injecting $IDENTITY ($LATEST_FILE) into ssh-agent..."
-  
-  # 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."