diff options
author | Greg Hartman <ghartman@google.com> | 2015-02-25 13:21:06 -0800 |
---|---|---|
committer | Greg Hartman <ghartman@google.com> | 2015-02-25 13:21:06 -0800 |
commit | bd77cf78387b72b7b3ea870459077672bf75c3b5 (patch) | |
tree | f3cbab24c7c8225d596b0beb47ffc4179bea273b /start-ssh | |
parent | 3c335c9fb9c12375ad62748fa1d1e5ebe4710c94 (diff) |
Put ssh back into the repository
Change-Id: I23324372188fa6ed3f93a32b84365f5df6367590
Diffstat (limited to 'start-ssh')
-rwxr-xr-x | start-ssh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/start-ssh b/start-ssh new file mode 100755 index 00000000..62d87dae --- /dev/null +++ b/start-ssh @@ -0,0 +1,37 @@ +#!/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 +DEFAULT_AUTHORIZED_KEYS=/system/etc/security/authorized_keys.default + +if [ ! -f $DSA_KEY ]; then + /system/bin/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 $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 |