HOWTO: enable SSH on Android and network ADB

Activate debugging and network debugging on the android device. Find out the IP of your android device.

Run adb on your computer connecting to android over the network:

adb connect
# displays "connected" message
adb shell
# displays "uid=0(root) gid=0(root)"

Enabling SSH:

Push your public key to the android device to allow password-less ssh login:

adb push ~/.ssh/ /sdcard/authorized_keys

Jump into a shell using adb (see above) and enable ssh:

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
killall dropbear
dropbear -v -s -g

Then create /system/etc/init.d/30sshd with the following contents:

(you may have to “mount -o remount,rw /system” in order to write to that file)

dropbear -v -s -g


Leave a Reply

Your email address will not be published. Required fields are marked *