This site runs best with JavaScript enabled.

SSH into Termux from Your Computer

April 06, 2021

––– views


The other day, I was debugging something on my Android phone (Pixel 2). Instead of typing on the phone, I thought it would be easier to SSH into Termux from my laptop.

It took me a while to get everything working so I figured I'd write up a post to help me remember next time (and hopefully help you!).

Follow these steps:

  1. Open Termux on your Android phone
  2. Install OpenSSH:
    pkg upgrade
    pkg install openssh
  3. Set up a password:
    passwd
  4. Find your username by running this in Termux:
    whoami
    Save this value for later. Might look like u0_a254
  5. Find the host by running this in Termux:
    ipconfig
    Look for something like inet addr:192.168.0.100 Save this value for later.
  6. Start the ssh server on Termux:
    sshd
    Verify that it's running with:
    logcat -s 'ssh:*'
    You should see something like "Server listening on port 8022"
  7. On your computer, SSH into your machine on port 8022 (default port):
    ssh <username>@<jjhost> -p8022
  8. Type in your password and viola! You're accessing Termux from your computer.

Additional Resources

These are the resources that helped me figure this out and might provide more context.

Remember, ssh depends on your network settings. If you're having issues with the ssh part (possibly if your phone is connected to a celluar network instead of WiFi), you can try this:

sshd -e -d -d -d

Discuss on TwitterEdit post on GitHub

Share article

Join the Newsletter

I send a couple emails per month related to programming and learning. I also share goodies and deals here.



Help others learn to code