Sunday, July 2, 2017

Ubuntu - SSH in to Android Phone (Google Pixel)

The ability to SSH in to your (unrooted) Android Phone is a very powerful one to have, and it is surprisingly simple.


  1. Install the "SimpleSSHD" app on your phone (form the Google Play Store).
  2. Copy your PUBLIC ssh key (form your computer) to the "/sdcard/ssh" (default) folder on your phone and rename it authorized_keys.
  3. Run the "SimpleSSHD" app and click start (uses port 2222 be default since it runs in user space). The app will tell you the IP address of the phone.
  4. SSH in to your phone by issuing:
    ssh -o StrictHostKeyChecking=no -p 2222 -i <private key location> <phone ip address>
    You will need to issue StrictHostKeyChecking=no the first time only.
  5. To avoid having to type all of this out every time you can add a section to the ssh config file (~/.ssh/config).
    Host pixel
    
        Hostname 192.168.42.129
        Port 2222
        IdentityFile ~/.ssh/pixel
    
    and simply run ssh pixel to connect.
Nore: This technique works with USB tethering as well. SimpleSSHD will show both the WiFi and the USB Tethering IP Addresses and you can use the latter for super-fast ssh.

No comments:

Post a Comment