Debian Codegraph @

src/lsh-authorize

raw
1 #! /bin/sh
2
3 usage () {
4 echo Usage: $0 key-file
5 }
6
7 while [ $# != 0 ]; do
8 case $1 in
9 -help | --help | --hel | --he)
10 usage
11 exit 0
12 ;;
13 --*)
14 echo Unknown option $1
15 usage
16 exit 1
17 ;;
18 *)
19 break
20 ;;
21 esac
22
23 options="$options $1"
24 shift
25 done
26
27 if [ $# = 0 ] ; then
28 usage
29 exit 0
30 fi
31
32 create_dir () {
33 if mkdir $1 2>/dev/null; then
34 echo Created $1
35 chmod $2 $1 || exit 1
36 fi
37 }
38
39 # Create directories
40 create_dir $HOME/.lsh 0700
41 create_dir $HOME/.lsh/authorized_keys_sha1 0700
42
43 : ${SEXP_CONV:=sexp-conv}
44
45 if type "$SEXP_CONV" >/dev/null 2>&1 ; then : ; else
46 echo "Can't find the sexp-conv program"
47 exit 1
48 fi
49
50 while [ $# != 0 ]; do
51 hash=`"$SEXP_CONV" < $1 --once --hash=sha1`
52 if [ -z $hash ] ; then
53 echo $0: File $1 not found.
54 exit 1
55 else
56 "$SEXP_CONV" < $1 -s canonical --once \
57 > "$HOME/.lsh/authorized_keys_sha1/$hash" \
58 || exit 1
59 fi
60 shift
61 done