Termux is an Android terminal emulator and Linux environment app that allows you to run command-line programs and scripts on your Android device. It provides a full Linux environment with package management using APT, allowing you to install and use various tools and utilities on your Android device.
Termux-api is a python module to access the termux-api This provides a way to get native access in Python to Android device functionality as API.
SSH stands for Secure Shell. It is a cryptographic network protocol that allows secure communication between two devices over an insecure network. SSH is commonly used for remote login to a server or computer, allowing users to access a command-line interface and execute commands on a remote machine securely.
• f-droid
• Termux
pkg update -y
pkg install openssh termux-api -y
ifconfig
(note inet address: 192.168.1.228) whoami
(note the username: u0-a564) passwd
(to set desired password) sshd
(to start ssh in the background) ssh [email protected] -p 8022
or:
ssh 192.168.1.228 -p 8022
Port 8022 is not the default SSH port, which is 22. Changing the SSH port from the default 22 to a different port, like 8022, can be a security measure. Using a non-standard port can make it harder for unauthorized users or automated bots to find and potentially exploit your SSH server.
additional dependencies:
apt install x11-rep root-repo unstable-repo
Let’s see what commands we can run using Termux API:
Command | Description |
---|---|
termux-setup-storage |
Access shared storage |
termux-battery-status |
Check battery status |
termux-sms-send -n 01235678910 hello |
Send an SMS |
termux-microphone-record -f ~/out.mp3 |
Record audio to ~/out.mp3 |
termux-microphone-record -q |
Stop recording audio |
termux-clipboard-set "hello word" |
Set clipboard text to “hello word” |
termux-clipboard-get |
Print clipboard text |
termux-sensor -l |
List available sensors |
termux-torch on |
Turn on torch (off to switch off) |
termux-camera-photo photo.jpg |
Take a picture and save as photo.jpg |
termux-tts-speak "hello how what are you doing" |
Text-to-speech, phone speaks the text |
You can find additional information and full list of termux api commands on the official page of the Termux API:
Termux:API wikiSFTP, or Secure File Transfer Protocol, is a network protocol designed for secure file access and transfer. It encrypts both commands and data, ensuring a safe transfer of files between clients and servers.
See SSH section ↑
to find your host IP address: ifconfig (inet address)
In Termux, sudo is a command that allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. It is used to perform administrative tasks that require elevated privileges on the Android device within the Termux environment.
apt install git tsu x11-repo android-tools
git clone https://gitlab.com/st42/termux-sudo
cd termux-sudo
cat sudo > /data/data/com.termux/files/usr/bin/sudo
chmod 700 /data/data/com.termux/files/usr/bin/sudo
Commands if an error occurs:
YouTube’s walkthrough video by Kris Occhipinti
ssh [email protected] -p 8022 "sudo screenrecord --output-format=h264 -"| ffplay - 2>/dev/null
ssh [email protected] -p 8022 "ffmpeg -f x11grab -i :0 -f avi - "| ffplay - &>/dev/null
/system/bin/screenrecord --output /data/data/com.termux/files/home/hello.mp4 --output-format=h264
ssh [email protected] -p8022 "sudo screenrecord --output-format=h264 -"| ffplay - 2>/dev/null
Casting Android Screen Across Network with Busybox nc (this is not encrypted)
busybox nc -lp 8022|ffplay - 2>/dev/null
screenrecord --output-format=h264 -|busybox nc <DESKTOP IP> 8022
(busybox nc -lp 8022|ffplay - 2>/dev/null)&(adb shell screenrecord --output-format=h264 -|busybox nc <DESKTOP IP> 8022)
SCRCPY is a free and open-source application that allows you to display and control Android devices connected via USB or TCP/IP. It provides a way to mirror and control your Android device from a computer, offering features like screen mirroring, file transfer, and remote control of the Android device from the computer.
settings > about > software information > tap “Build number” 7 times > back to settings > developer options > enable USB debugging
click ok
download SCRCPY . Choose from Assets appropriate version mine is windows 64 bit so (scrcpy-win64-v2.4.zip) extract and go inside directory.
Once you’re in the scrcpy directory, open terminal and execute the following command:
./scrcpy
Termux offers a powerful Linux environment on Android devices, enabling users to run command-line programs, SSH into their devices, and manage various tasks efficiently. With the Termux API, users can further extend the functionality by accessing shared storage, controlling device sensors, sending SMS, and more, all from the command line. Additionally, tools like SFTP, sudo for elevated privileges, and screen sharing options like SCRCPY and SSH-based methods provide comprehensive control and flexibility for Android users, bridging the gap between mobile and desktop computing. Whether you’re a tech enthusiast or a developer, Termux opens up a world of possibilities for Android device customization and remote management.