Skip to content

Instantly share code, notes, and snippets.

@clevertonh
Forked from raveenb/ssh_into_android.md
Created July 26, 2021 15:20
Show Gist options
  • Save clevertonh/93c4d2ab604a567da47453c655f09eba to your computer and use it in GitHub Desktop.
Save clevertonh/93c4d2ab604a567da47453c655f09eba to your computer and use it in GitHub Desktop.
SSH into Android
  1. Install Android App Termux from APKPure or AppStore. If the app exists, just delete and re-install it, can be done quickly using
adb install ~/Downloads/Termux_v0.73_apkpure.com.apk
  1. Then run the app inside the android device, locate and tap on it

  2. Run the following commands inside the app, use the on device keyboard, (choose default option when asked question, just hit enter)

pkg install root-repo
pkg upgrade
pkg install openssh
  1. Set a password for the current user by passwd, remember this password you will need it later

  2. Start SSH server inside android by running sshd, do not close/exit the app after running the command

  3. On the pc terminal run the following, dont use root@ as prefix to the ip address

ssh <ip address of android device> -p 8022
  1. This will drop you into a shell where you can do further installs using pkg install <name>

  2. If for some odd reason you are getting Host key verification failed error, run the following first

ssh-keygen -R <ip address of android device>

If it still gives you trouble edit ~/.ssh/known_hosts, locate the line(s) with the ip address and delete it and then connect again


Extracted from Termux's wiki on this topic from here [https://wiki.termux.com/wiki/Remote_Access]

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