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.
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.
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.
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.
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.
sshd
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.
Port 2222
When you try to connect this SSH Server, it will ask password to connect. You cam set password by using the passwd command.
passwd
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.
ifconfig
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
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.
The Termux SSH server is very useful for a variety of purposes.
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.