blob: 851a6fdb0c8e3ced53c35b6954ef85a805e71516 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/bin/sh
set -u
set -e
SLOT="-2"
echo "Enter first factor passphrase (enter -1 to use slot one): " >&2
read -s first
if [[ "$first" == "-1" ]]; then
SLOT="-1"
echo "Using slot 1. Enter first factor passphrase: " >&2
read -s first
fi
response=''
until [[ "$response" != "" ]]; do
# A little side note about ykchalresp. Originally there was
# more comprehensive error handling here, but it was ugly
# because ykchalresp uses 1 for just about every failure
# mode. The stderr was different, but capturing both stdout
# and stderr is a real challenge in shell and relying on
# error messages is a bad idea (tm) anyway. So now stderr
# bubbles out to the user and this script loops until the
# user gives up.
echo "Use your Yubikey as a second factor: " >&2
if stdout=$(ykchalresp "$SLOT" "$first") ; then
response="$stdout"
else
echo "Press enter before trying again" >&2
read -s enter
fi
done
echo "$response"
|