blob: 4a9d1aeb7123c1c6530bac02719693fa94f829d4 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh
. /lib/functions.sh
enroll_atsign() {
local section="$1"
config_get atsign "$section" "atsign"
if [ -z "$atsign" ]; then
echo "sshnpd: atsign must be configured in /etc/config/sshnpd"
return 1
fi
config_get device "$section" "device"
if [ -z "$device" ]; then
echo "sshnpd: device must be configured in /etc/config/sshnpd"
return 1
fi
config_get otp "$section" "otp"
if [ -z "$otp" ]; then
echo "sshnpd: otp must be configured in /etc/config/sshnpd"
return 1
fi
config_get user "$section" user
if [ -z "$user" ]; then
user='root'
fi
config_get home "$section" home
if [ -z "$home" ]; then
if [ "$user" = "root" ]; then
home='/root'
else
home="/home/${user}"
fi
fi
if [ ! -d "${home}/.atsign/keys" ]; then
mkdir -p "${home}/.atsign/keys"
fi
if [ -f "${home}/.atsign/keys/${atsign}_key.atKeys" ]; then
echo "sshnpd: atsign keys file already present, exiting enrollment"
return 1
fi
echo
echo "To activate this enrollment run the following command line on a"
echo "system where the ${atsign} key has been activated:"
echo
echo "at_activate approve -a ${atsign} --arx noports --drx ${device}"
echo
at_activate enroll -a ${atsign} -s ${otp} -p noports \
-k ${home}/.atsign/keys/${atsign}_key.atKeys -d ${device} \
-n "sshnp:rw,sshrvd:rw"
}
config_load sshnpd
config_foreach enroll_atsign sshnpd
|