Back to course

Setting up SSH Access (Termux as an SSH Client)

Termux Masterclass: From Zero to Linux Power User on Android

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.

  1. Generate Key Pair: bash $ ssh-keygen -t ed25519 -f ~/.ssh/termux_key

    Enter a strong passphrase when prompted.

  2. Copy Public Key to Server: Use ssh-copy-id (if installed) or manually copy the contents of ~/.ssh/termux_key.pub to the ~/.ssh/authorized_keys file on the remote server.

  3. 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.