lsh-authorize 1.04 KB
Newer Older
1
2
#! /bin/sh

3
usage () {
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
    echo Usage: $0 key-file
}

while [ $# != 0 ]; do
    case $1 in
    	-help | --help | --hel | --he)
	    usage
	    exit 0
    	    ;;
	--*)
	    echo Unknown option $1
	    usage
	    exit 1
	    ;;
	*)
	    break
	    ;;
    esac

    options="$options $1"
    shift
done

if [ $# = 0 ] ; then
    usage
    exit 0
fi

32
create_dir () {
33
34
35
36
37
38
39
    if mkdir $1 2>/dev/null; then
	echo Created $1
	chmod $2 $1 || exit 1
    fi
}

# Create directories
40
41
create_dir $HOME/.lsh 0700
create_dir $HOME/.lsh/authorized_keys_sha1 0700
42

Niels Möller's avatar
Niels Möller committed
43
# FIXME: This test seems to not work properly with Solaris' /bin/sh.
44
if type sexp-conv &>/dev/null ; then
45
    SEXP_CONV=sexp-conv
46
else
47
    SEXP_CONV=./sexp-conv
48
fi
49

50
if type $SEXP_CONV &>/dev/null; then : ; else
51
    echo "Can't find the sexp-conv program"
52
53
54
55
56
57
58
59
    exit 1
fi

while [ $# != 0 ]; do
    hash=`$SEXP_CONV < $1 --once --hash sha1 --raw-hash`
    if [ -z $hash ] ; then
	echo $0: File $1 not found.
    else
60
        $SEXP_CONV < $1 -f canonical --once > $HOME/.lsh/authorized_keys_sha1/$hash
61
62
63
    fi
    shift
done