ssh daemon on Android with dropbear

The following procedures have been tested on my Motorola milestone with CyanogenMod v7.

We will use RSA key authentication only.

Dropbear is installed on CyanogenMod by default.
If it is not present, you can download and install it manually

Copy your private rsa-key to /sdcard/

cp ~/.ssh/ /sdcard/authorized_keys

Open terminal on your phone and do it:

mkdir /data/dropbear
mkdir /data/dropbear/.ssh
mv /sdcard/authorized_keys /data/dropbear/.ssh/
chown root:root /data/dropbear/.ssh/authorized_keys
dropbearkey -t rsa -f /data/dropbear/dropbear_rsa_host_key
dropbearkey -t dss -f /data/dropbear/dropbear_dss_host_key
chmod 755 /data/dropbear
chmod 644 /data/dropbear/dropbear*host_key
chmod 755 /data/dropbear/.ssh
chmod 600 /data/dropbear/.ssh/authorized_keys

Now make it auto start when your phone boots.
Remount /system partition

mount -o remount,rw `mount |grep system | awk {'print $1'}` /system

Create /system/etc/init.d/30sshd with the following contents, and make it executable:

dropbear -s -g

You can start dropbear manually or restart your phone.

coded by nessus