36. Setting up SSH Access (Termux as an SSH Client)
SSH (Secure Shell) is vital for securely connecting to and managing remote servers. Termux includes a robust SSH client (ssh) by default.
1. Checking the Client
If you performed initial setup, the client should already be available.
bash $ ssh -V OpenSSH_9.7p1, OpenSSL 3.1.5 13 Feb 2024
2. Basic SSH Connection
To connect to a remote server, you need the username and the server's address (IP or domain).
bash $ ssh username@server_ip_address
Termux will prompt you for the remote user's password. The first time you connect, it will ask to save the server's key fingerprint.
3. Using SSH Keys (Passwordless Access)
Using keys is more secure and convenient than passwords. You need to generate a key pair on your Termux device.
-
Generate Key Pair: bash $ ssh-keygen -t ed25519 -f ~/.ssh/termux_key
Enter a strong passphrase when prompted.
-
Copy Public Key to Server: Use
ssh-copy-id(if installed) or manually copy the contents of~/.ssh/termux_key.pubto the~/.ssh/authorized_keysfile on the remote server. -
Connect Using Key: bash $ ssh -i ~/.ssh/termux_key username@server_ip_address
This setup turns your Android device into a powerful mobile management tool.