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