forked from nvllsvm/freecyngn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
99sshd.sh
42 lines (33 loc) · 1.12 KB
/
99sshd.sh
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
#!/system/bin/sh
umask 077
# DEBUG=1
DSA_KEY=/data/ssh/ssh_host_dsa_key
DSA_PUB_KEY=/data/ssh/ssh_host_dsa_key.pub
RSA_KEY=/data/ssh/ssh_host_rsa_key
RSA_PUB_KEY=/data/ssh/ssh_host_rsa_key.pub
AUTHORIZED_KEYS=/data/.ssh/authorized_keys
OLD_AUTHORIZED_KEYS=/data/ssh/authorized_keys
DEFAULT_AUTHORIZED_KEYS=/system/etc/security/authorized_keys.default
if [ ! -f $DSA_KEY ]; then
ssh-keygen -t dsa -f $DSA_KEY -N ""
chmod 600 /$DSA_KEY
chmod 644 $DSA_PUB_KEY
fi
if [ ! -f $RSA_KEY ]; then
/system/bin/ssh-keygen -t rsa -f $RSA_KEY -N ""
chmod 600 /$RSA_KEY
chmod 644 $RSA_PUB_KEY
fi
if [[ -f $OLD_AUTHORIZED_KEYS && ! -f $AUTHORIZED_KEYS ]]; then
cat $OLD_AUTHORIZED_KEYS > $AUTHORIZED_KEYS
fi
if [[ ! -f $AUTHORIZED_KEYS && -f $DEFAULT_AUTHORIZED_KEYS ]]; then
cat $DEFAULT_AUTHORIZED_KEYS > $AUTHORIZED_KEYS
fi
if [ "1" == "$DEBUG" ] ; then
# run sshd in debug mode and capture output to logcat
/system/bin/logwrapper /system/bin/sshd -f /system/etc/ssh/sshd_config -D -d
else
# don't daemonize - otherwise we can't stop the sshd service
/system/bin/sshd -f /system/etc/ssh/sshd_config -D
fi