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