How to SSH to Termux Shell
Introduction
Easy way to ssh to termux shell running on Android
Prerequisites
- A device running Android with Termux installed
- A Linux machine with OpenSSH installed
Steps
- Find the IP address of termux using the following command
ip addr | grep 192
- install open ssh
- start ssh service using the following
sshd
- Find hostname of termux machine using
hostname
command - From host machine, perform ssh using the following command
ssh -p 8022 $hostname@$phoneIp
- The END
Conclusion
Tada, You’ve successfully done ssh to termux✨
Use termux to start web-servers (Apache, Nginx etc) just like you would normally do in a Linux machine and you can expose it to the internet using free services like ngrok.
Bonus Tip
replace ssh
in step 5 using sftp
and suddenly you now have an extremely safe and easy way to transfer files to and from your phone. You’re welcome😊
Troubleshooting
- Connection refused: Make sure that your device is connected to the same network as your Linux machine and that the SSH service is running on Termux.
- Incorrect IP address: Double-check that you have the correct IP address of your device.
- Firewall issues: Make sure that your firewall is not blocking the SSH connection.