Debian Codegraph @

src/ssh-conv

raw
1 #! /bin/sh
2
3 SSH_CONV="lsh-decode-key"
4
5 while [ $# -ge 1 ]; do
6 case "$1" in
7 --usage|--help)
8 echo "Usage: ssh-conv [OPTION]"
9 echo "Converts an OpenSSH style public key to spki format."
10 echo
11 echo " --decode-with PROGRAM-NAME The program to use for the"
12 echo " actual decoding."
13 echo
14 echo "Report bugs to <[email protected]>."
15 exit 0
16 ;;
17 --decode-with)
18 shift
19 SSH_CONV=$1
20 ;;
21 *)
22 echo "ssh-conv: unrecognized option \`$1'"
23 echo "Try \`ssh-conv --help' or \`ssh-conv --usage' for more information."
24 exit 1
25 ;;
26 esac
27 shift
28 done
29
30 if type "$SSH_CONV" >/dev/null 2>&1; then : ; else
31 echo "ssh-conv: Can't find the program \`$SSH_CONV'."
32 exit 1
33 fi
34
35 awk 'BEGIN { state = 0; }
36 state == 0 && /^---- BEGIN SSH2 PUBLIC KEY/ { state = 1; next; }
37 state == 1 && $0 ~ /^---- END SSH2 PUBLIC KEY/ { state = 2 }
38 state == 1 && $0 !~ /:/ { print }
39 state == 2 { next }
40 state == 0 && /^ssh-dss/ { print $2; }
41 state == 0 && /^ssh-rsa/ { print $2; }' \
42 | $SSH_CONV -b