• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/system/bin/sh
2
3umask 077
4
5# DEBUG=1
6
7DSA_KEY=/data/ssh/ssh_host_dsa_key
8DSA_PUB_KEY=/data/ssh/ssh_host_dsa_key.pub
9RSA_KEY=/data/ssh/ssh_host_rsa_key
10RSA_PUB_KEY=/data/ssh/ssh_host_rsa_key.pub
11AUTHORIZED_KEYS=/data/ssh/authorized_keys
12DEFAULT_AUTHORIZED_KEYS=/system/etc/security/authorized_keys.default
13
14if [ ! -f $DSA_KEY ]; then
15    /system/bin/ssh-keygen -t dsa -f $DSA_KEY -N ""
16    chmod 600 /$DSA_KEY
17    chmod 644 $DSA_PUB_KEY
18fi
19
20if [ ! -f $RSA_KEY ]; then
21    /system/bin/ssh-keygen -t rsa -f $RSA_KEY -N ""
22    chmod 600 /$RSA_KEY
23    chmod 644 $RSA_PUB_KEY
24fi
25
26if [[ ! -f $AUTHORIZED_KEYS && -f $DEFAULT_AUTHORIZED_KEYS ]]; then
27    cat $DEFAULT_AUTHORIZED_KEYS > $AUTHORIZED_KEYS
28fi
29
30
31if [ "1" == "$DEBUG" ] ; then
32    # run sshd in debug mode and capture output to logcat
33    /system/bin/logwrapper /system/bin/sshd -f /system/etc/ssh/sshd_config -D -d
34else
35    # don't daemonize - otherwise we can't stop the sshd service
36    /system/bin/sshd -f /system/etc/ssh/sshd_config -D
37fi
38