Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hkfuertes/4d6a1244b28d82e5134c16385c6d9486 to your computer and use it in GitHub Desktop.
Save hkfuertes/4d6a1244b28d82e5134c16385c6d9486 to your computer and use it in GitHub Desktop.
TWRP Enable ADB with Keys

TWRP Enable ADB with Keys

To enable adb debuging from recovery (TWRP):

adb shell

# Data related changes
twrp mount data
mkdir /data/property
echo -n 'mtp,adb' > /data/property/persist.sys.usb.config

# System related changes
twrp remountrw system
# This next command should return empty
grep 'persist.service.adb.enable' /system/build.prop
echo '' >> /system/build.prop
echo '# Enable ADB' >> /system/build.prop
echo 'persist.service.adb.enable=1' >> /system/build.prop 
echo 'persist.service.debuggable=1' >> /system/build.prop
echo 'persist.sys.usb.config=mtp,adb' >> /system/build.prop 

RSA verification

Generate the public key and push it to device:

adb pubkey ~/.android/adbkey > ~/.android/adbkey.pub
adb push ~/.android/adbkey.pub /data/misc/adb/adb_keys
adb shell chmod 766 /data/misc/adb/adb_keys

sudo cp /lib/udev/rules.d/51-android.rules /etc/udev/rules.d/

TWRP cmdline commands: https://twrp.me/faq/openrecoveryscript.html

Wifi config

https://stackoverflow.com/questions/8708886/connecting-to-wifi-using-adb-shell

@hkfuertes
Copy link
Author

New

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment