aboutsummaryrefslogtreecommitdiffstats
path: root/modules/security/ssh/gpg-ssh-key-load.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules/security/ssh/gpg-ssh-key-load.sh')
-rw-r--r--modules/security/ssh/gpg-ssh-key-load.sh33
1 files changed, 18 insertions, 15 deletions
diff --git a/modules/security/ssh/gpg-ssh-key-load.sh b/modules/security/ssh/gpg-ssh-key-load.sh
index 02dda1d..b9567f8 100644
--- a/modules/security/ssh/gpg-ssh-key-load.sh
+++ b/modules/security/ssh/gpg-ssh-key-load.sh
@@ -15,10 +15,13 @@ export GNUPGHOME="@@GNUPGHOME@@"
GOPASS_SSH_KEY="@@GOPASS_SSH_KEY@@"
-info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
-warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
-die() { error "$*"; exit 1; }
+die() {
+ error "$*"
+ exit 1
+}
usage() {
cat <<EOF
@@ -34,15 +37,15 @@ EOF
while [[ $# -gt 0 ]]; do
case "$1" in
- --help | -h)
- usage
- exit 0
- ;;
- *)
- error "Unknown option: $1"
- usage
- exit 1
- ;;
+ --help | -h)
+ usage
+ exit 0
+ ;;
+ *)
+ error "Unknown option: $1"
+ usage
+ exit 1
+ ;;
esac
done
@@ -60,14 +63,14 @@ if ssh-add -l 2>/dev/null | grep -qE "(ED25519|RSA|ECDSA)"; then
exit 0
fi
-if ! gopass show -o "$GOPASS_SSH_KEY" > /dev/null 2>&1; then
+if ! gopass show -o "$GOPASS_SSH_KEY" >/dev/null 2>&1; then
die "no gopass entry $GOPASS_SSH_KEY"
fi
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
keyfile="$tmpdir/key"
-gopass show -o "$GOPASS_SSH_KEY" > "$keyfile" 2>/dev/null
+gopass show -o "$GOPASS_SSH_KEY" >"$keyfile" 2>/dev/null
chmod 600 "$keyfile"
passphrase=$(gopass show -o "$GOPASS_SSH_KEY/passphrase" 2>/dev/null || true)
@@ -82,4 +85,4 @@ if ! timeout 60 ssh-add "$keyfile"; then
exit 1
fi
-info "SSH key loaded into gpg-agent." \ No newline at end of file
+info "SSH key loaded into gpg-agent."