1 #!/system/bin/sh 2 3 umask 077 4 5 # DEBUG=1 6 7 DSA_KEY=/data/ssh/ssh_host_dsa_key 8 DSA_PUB_KEY=/data/ssh/ssh_host_dsa_key.pub 9 RSA_KEY=/data/ssh/ssh_host_rsa_key 10 RSA_PUB_KEY=/data/ssh/ssh_host_rsa_key.pub 11 AUTHORIZED_KEYS=/data/ssh/authorized_keys 12 DEFAULT_AUTHORIZED_KEYS=/system/etc/security/authorized_keys.default 13 14 if [ ! -f $DSA_KEY ]; then 15 ssh-keygen -t dsa -f $DSA_KEY -N "" 16 chmod 600 /$DSA_KEY 17 chmod 644 $DSA_PUB_KEY 18 fi 19 20 if [ ! -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 24 fi 25 26 if [[ ! -f $AUTHORIZED_KEYS && -f $DEFAULT_AUTHORIZED_KEYS ]]; then 27 cat $DEFAULT_AUTHORIZED_KEYS > $AUTHORIZED_KEYS 28 fi 29 30 31 if [ "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 34 else 35 # don't daemonize - otherwise we can't stop the sshd service 36 /system/bin/sshd -f /system/etc/ssh/sshd_config -D 37 fi 38