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:
- Open Termux on your Android phone
- Install OpenSSH:
pkg upgrade pkg install openssh
- Set up a password:
passwd
- Find your username by running this in Termux:
Save this value for later. Might look likewhoami
u0_a254
- Find the host by running this in Termux:
Look for something likeipconfig
inet addr:192.168.0.100
Save this value for later. - Start the ssh server on Termux:
Verify that it’s running with:sshd
You should see something like “Server listening on port 8022”logcat -s 'ssh:*'
- On your computer, SSH into your machine on port 8022 (default port):
ssh <username>@<jjhost> -p8022
- 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