Breaking News

Monday 14 September 2020

How To Install SSH On Termux

 

How To Install SSH On Termux

Hello guys I am back. In  this post, am going to tell you how you can use SSH on your Android phone using Termux


Termux is a powerful terminal emulation for Android, with broad community and robust package manager. Making it easier to run Linux computing right in your pocket these days.
This article will explain to you how to set up an SSH Server in Termux and allow you to connect to it from any client in your network.
 let's see how we can use SSH on Termux

If you're new to SSH then let me explain a little bit about SSH


WHAT IS SSH?

According to the Google

'"Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line, login, and remote command execution, but any network service can be secured with SSH."'

In simple words, SSH is a protocol that helps two Computers to communicate
SSH is used to login to a remote computer and execute commands, file transfer and to perform many other things


INSTALLING REQUIRED PACKAGES


Ensure everything is up to date
$ pkg upgrade
Install the OpenSSH package
$ pkg install openssh

To start the SSH server, run this command
$ sshd
If you need to kill the server, just kill its process


$ pkill sshd

Setting up password authentication

Ideally, we should set up key authentication, but for the sake of simplicity, I’m gonna skip that part, keep in mind that password authentication is less secure than key authentication.

Password authentication is enabled by default on termux, but you can still review the configuration by running
$ cat $PREFIX/etc/ssh/sshd_config

It should look pretty much like this


PrintMotd yes
PasswordAuthentication yes
PubkeyAcceptedKeyTypes +ssh-dss
Subsystem sftp /data/data/com.termux/files/usr/libexec/sftp-server

Set new password
$ passwd
New password:
Retype new password:
New password was successfully set.
At this point, we’re ready to start the SSH Server and connect to the android device.


Connecting from remote machine

First of all, we need to know the android device IP address on the device, get this by running


$ ifconfig

From this output, we know that the device IP address on the network is 192.168.100.92




wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.92  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::d4d0:8cac:6318:8ac9  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 1118178  bytes 1321397645 (1.2 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 577939  bytes 80497172 (76.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

We’re ready to connect to the android device from remote

# ssh anything@192.168.100.92 -p 8022

You can connect using any username because termux doesn’t care. In this example, I use anything.

Put in the password you’ve setup before, after that, you’re in.

0 comments:

Post a Comment

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();
'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();