unlocks.sh

SSH Keychain komfortabel mit Schlüsseln vollschaufeln, ohne in Fehler zu rennen Shell Script!!1!

 1#!/bin/sh
 2
 3SSH_ADD=$(which "ssh-add")
 4SSH_KEY=$(which "ssh-keygen")
 5
 6msg () { echo "$(basename "$0") | $*"; }
 7
 8KEY_FILE="${KEY-"$1"}"
 9if [ -z "$KEY_FILE" ]; then
10    msg "specify key file, please."
11    exit 1
12fi
13msg "$KEY_FILE"
14
15KEY_INFO=$($SSH_KEY -lf "$KEY_FILE" 2>&1)
16KEY_CODE=$?
17
18msg "$KEY_INFO"
19if [ $KEY_CODE -ne  0 ]; then
20    msg "error" "[$KEY_CODE]"
21    exit $KEY_CODE
22fi
23
24KEY_HASH=$(echo "$KEY_INFO" | cut -d' ' -f2)
25if $SSH_ADD -l | grep -q "$KEY_HASH"; then
26    msg "already unlocked."
27    exit 0
28fi
29
30$SSH_ADD "$KEY_FILE"
31exit $?
  • platformunabhängig

  • posix

  • verteiltes echtzeitjava

  • zertifiziert

  • banane