Joe PreviteJoe PreviteSee all posts

SSH into Termux from Your Computer

Last updated:

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

Join the Newsletter

I send a monthly newsletter with 1 exciting thing, 1 helpful thing, and new jobs.

By subscribing, you agree with Revue’s Terms of Service and Privacy Policy.