OpenSSH in Termux includes SSH client, server, secure FTP, SCP, and more, enabling your device to act as both client & server. Check out installation & usage.
Table Of Contents.
What Is SSH?
SSH in Termux is a secure way to access a remote computer from your Android device. It uses the Secure Shell (SSH) protocol to encrypt all traffic between your device and the remote computer, protecting your data from eavesdropping and other attacks.
Install SSH In Termux Android
To use SSH in Termux, you need to install the openssh suite that include various ssh tools. Run following commands to install:
Update Termux Repository.
pkg update && pkg upgrade
Install openssh package.
pkg install openssh
After openssh package is installed, you can start the SSH server or Connect to Remote Device as client.
List Of OpenSSH Suite Tools In Termux.
OpenSSH provides a suite of tools for secure networking, which includes following tools:
ssh – The SSH client: Used to connect to a remote Device.
sshd – The SSH server: Used to allow remote device to connect to your device.
sftp – A secure file transfer protocol: Uses SSH for encryption to transfer files over network.
scp – The SSH secure copy tool: Used to copy files between Devices.
ssh-keygen – The SSH key generation tool: Used to generate SSH key pairs.
ssh-copy-id – The SSH key copy tool: Used to copy an SSH public key to a remote Device.
How To Start SSH Server?
The SSH server in Termux can be used to access your Termux instance remotely from another device. Run the following command to start SSH Server.
The SSH server listens on port 8022 by default in. You can change the port number by editing the $PREFIX/etc/ssh/sshd_config file. For example if you want to change port to 2222 then add the following code.
When you try to connect this SSH Server, it will ask password to connect. You cam set password by using the passwd command.
How To Connect To SSH Server.
The ssh command allows you to run Termux commands remotely. After starting the SSH Server in Termux, you can connect it by running the following command.
ssh -p 8022 localhost
First time it will ask to add key to the known host. Type yes to continue. Then enter password that you have set using passwd command.
In above command localhost is the IP address of your device. If you are connected to the network you can access your device within the network. Just find out your local network IP address and replace it by localhost.
Run ifconfig command to find wlan ip.
As you can see the IP address is 192.168.43.1 so run the following command from other connected device.
ssh -p 8022 192.168.43.1
Using SFTP to Transfer Files.
SFTP stands for Secure File Transfer Protocol. It is Subsystem of SSH Server started with SSH Server. In Termux, SFTP can be used to transfer files between your Android device and another computer, or between two Android devices. Run following command to access files using SFTP.
sftp -P 8022 <ip_address>
Replace ip_address by your Android device IP.
Note: where you are using sftp with command for Termux intense use capital -P option.
When you login to SFTP run help command to see the SFTP command list. These commands are similer to FTP commands. Use get command to download files and put command to upload files to the Termux Intense.
Use of SSH In Termux Android
The Termux SSH server is very useful for a variety of purposes.
- Accessing your Termux instance remotely from another computer.
- Running scripts and commands on your Termux instance from another computer.
- Transferring files between your Termux instance and another computer.
- Connecting to a remote server. This can be useful if you want to access a server that is not on your local network.
- Using external apps to browse Termux Filesystem or write codes.
Overall, Using SSH Server, Client and SFTP can be very useful for variety of purposes. If you are using Termux then SSH Tools can be must tools for you.