diff options
| author | tslil clingman <> | 2019-04-09 10:28:33 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2019-04-09 10:28:33 -0400 |
| commit | d3c79596d15feb7d3c435636535fa6911df0f96e (patch) | |
| tree | 66530d2475c9fd268f742975d6b7233f39b0bab3 | |
| parent | 71fc4f9e3e48e77049570260c8e593d877d8fbd8 (diff) | |
SSH key juggling
| -rwxr-xr-x | badpass | 42 | ||||
| -rwxr-xr-x | unlock_keys | 8 |
2 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,42 @@ +#!/bin/sh + +# Requires expect + +PREFIX="THIS IS TOTALLY SUPER SECRET" +PHRASE="THIS IS TOTALLY SUPER SECRET" + +# Supress echo, and trap exit for correct restoration +stty -echo +trap 'stty echo' EXIT + +# Read without processing at all +IFS="" +read -r MASTER + +# Restore state +stty echo +trap - EXIT + +USEECHO () { + echo $1 $2 +} + +USEKEYCHAIN () { + expect - <<EOF +spawn keychain --nogui --quiet $1 +expect { + "Enter passphrase for $HOME/.ssh/$1:"; { send "$2\n"; } +} +EOF +} + +CALL=USEECHO +if [ "$1" = "-k" ]; then + CALL=USEKEYCHAIN + shift +fi; + +for NAME in "$@"; do + PREPASS=$(echo $NAME$PHRASE$MASTER | sha256sum | cut -b -24) + $CALL $NAME $PREFIX$PREPASS +done diff --git a/unlock_keys b/unlock_keys new file mode 100755 index 0000000..a88674f --- /dev/null +++ b/unlock_keys @@ -0,0 +1,8 @@ +#!/bin/sh + +eval $(keychain --eval -q --systemd) + +KEY_FILES=$(ls $HOME/.ssh | grep -v '\(pub$\|^config$\|^known_hosts$\|^autohrized_keys$\)') +echo -n "Master password: " +badpass -k $KEY_FILES +echo Done! |
