Termux SSH : Use Termux in Windows Using SSH Server

In My Prievurs Post, I showed You, How you can Install Termux in Windows but those methods take a lot of space in your computer or they are not exactly termux. So in this post, I am gonna show you how you can Use SSH Server In Termux to use termux in your Windows Terminal. We will not install the actual termux in windows but we will use it with Remote Access.



What is SSH Server in Termux?

SSH stands for secure shell and it a cryptographic network protocol. With The help of ssh two computers can access data without any third person intercepting in between. It is more secure than other protocols because it is encrypted. You can use ssh in Termux to make a Private tunnel for you so that you can access your Termux in Windows easily.

Termux SSH : Use Termux in Windows Using SSH Server

Termux is CLI-based so while accessing the termux in Windows you will feel like its installed in your computer. It never lags, It does not disconnect, and it never malfunctions, You can easily install tools while using it with windows If you have a Windows then You should try this. 

You can also access it and set up your termux fully like a hacking machine, like installing tools and creating all the files that you can use any time you want. I have only tested it on Windows 10 and it works perfectly but maybe Windows 7 & 8 do not have ssh preinstalled if this method does not work for you then I have Written this Post for you Guys : Termux Tmate : Access Termux Remotely In Any Browser ]



Use Termux in Windows using SSH Server:

Please read this article carefully because this one is not just copied and paste, if you miss any part then it won't work. 


Step 1:

First of all, we will install OpenSSH and Nmap in termux using the basic pkg command. Nmap will show us the open ssh ports in the termux. The size of open-ssh in termux is almost 2.26 MB so it will be installed in Seconds. nmap is also a small 4.8Mb  package. Just Paste the below command and the open-SSH and nmap will be installed in termux.
pkg install openssh nmap -y
Termux SSH : Use Termux in Windows Using SSH Server


Step 2:

Now Run the ssh server by typing the below command. This command will start ssh server in your termux app.

sshd
Termux SSH : Use Termux in Windows Using SSH Server

 

Step 3:

Now the server is running and you have to set up a password for user in termux type the below command in termux and copy your username.

whoami

Termux SSH : Use Termux in Windows Using SSH Server

make sure you copy the full name as given in the above picture.


Step 4:

After copying the username we have to set up a password for it by typing the below command, Just paste your username in the green part of the command and Press enter.

passwd u0_a298
Termux SSH : Use Termux in Windows Using SSH Server

after pressing enter, it will ask you to enter a password, you have to type any password you want but make sure you won't forget it (just type 1234). after you type your password and press enter, it will ask you to retype your password, Just type the same password again. Also, it will not show you what you are typing but it's there so it's just invisible but the password is there.  


Step 5:

Now you have to find your local IP Address, Make sure your computer and your phone is on the same Wifi network or it won't work. Type the below command to find out your IP-Address.

ifconfig wlan0
Termux SSH : Use Termux in Windows Using SSH Server

You will find your own IP address at the same location I have shown in the above picture.



Step 6:

There is one more thing that we need is the ssh port, that you just have to type the below command and you will see your ssh port number ( mostly it will be 8022).

nmap localhost
Termux SSH : Use Termux in Windows Using SSH Server

In the above picture, you can see that my ssh port is on 8022. If you don't see any port then you should type sshd and then again run nmap localhost.



Step 7:

This is Step is the main Step, Now open the command prompt on your computer by pressing CTRL+ R and then type cmd and press enter. Now here you have to type the command to connect your termux with your Command prompt.

ssh username@your-Ip-asdress -p portnumber
Termux SSH : Use Termux in Windows Using SSH Server

 example: ssh u0_a298@192.168.1.201 -p 8022 

In the above command, you have to enter your username in the green part, You have enter your IP address at the pink part and the port number at the red part. Type the correct command and press Enter.



Step 8:

After you type the correct command and press enter you will see, in the last line it says that "are you sure you wanna continue connecting" Just type Yes press Enter. And Now you have to type your password that you used while setup, type that password and Press Enter and you will be inside your Termux Terminal.

Termux SSH : Use Termux in Windows Using SSH Server



Output :

This is your original termux accessed by the ssh in your windows and whatever you install and create will also be created in your termux but you don't have to turn on your termux for that, just run the server lock the phone, and use it in your PC.

Termux SSH : Use Termux in Windows Using SSH Server



How to resolve sshd: no hostkeys available -- exiting Error in Termux?

If you delete your termux data or maybe reinstall the new version of termux, you might see this issue popping up whenever you will try to execute the sshd command. This can be solved using the below single command. just type this and wait for 1 second. 
ssh-keygen -A
after typing this command, run sshd command again and it will work fine.

How to Close the SSH server in Termux?

To close the ssh serve you can always close or exit your termux and the ssh server will automatically be turned off but if you don't wanna close your termux then you can kill the ssh process using the below command.
pkill ssh
Termux SSH : Use Termux in Windows Using SSH Server


How to Restart the SSH server in Termux?

Everything is setup and you want to use it a second time then you don't have to follow the steps from the start you just have to type sshd and use the command in step 7 and type it in windows and if your IP is the same then it will connect But if your IP is changed you have to follow from step 5. Also Windows 7 & 8 do not have ssh preinstalled if this method does not work for you then I have Written this Post for you Guys : Termux Tmate : Access Termux Remotely In Any Browser ]



[Update] Live Screen Mirror While doing SSH in Termux?

Now you know how you can easily access anyone's system using SSH, but what if you want to work with them live? What if you want the other person to see what you are doing on their PC? If you want both people to access the same terminal and see live updates on the screen, you can follow the below method.

Step 1:

Firstly, You have to install the screen package in termux. This package allows you to see live update on both the terminals while they are in one common SSH shell. 

pkg install screen


Step 2:

Now when both devices are connected in an SSH shell, on the primary device you have to type the below command.

screen -S nix

And on the secondary device have to type the below command. 

screen -x nix

Above, both the commands are interchangeable, and you just have to put these 2 commands in 2 separate devices while they are on the same SHH shell, and you will be able to see the live screen updates.



Conclusion:

Termux SSH is the best method for accessing termux on your windows PC. It looks complicated but its really simple to install and after a one-time installation, it is so easy to use every day. It tried to make this tutorial simple but if you are still facing issues while using this method then comment down below and I will make a Lazy Script for this. Keep in mind that when you reinstall your termux then you have to set up it again. If you want to install a real termux in your Computer then you can read this post : [ Termux for PC | How to install Termux in Windows - 2020 ]. I barely used Nmap in this post but you can Learn about Nmap completely by reading this post [ Install and Use Nmap in Termux ]. Thanks for reading Guys, Stay Inspired and as always Stay Ethical.👾  

Post a Comment

4 Comments

  1. my pc tells me ssh is not recognised as an internal or external command,
    operable program or batch file.
    in my command prompt

    ReplyDelete
    Replies
    1. You need an SSH client, like PuTTY (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html). Some newer versions of windows may have the "ssh" program installed for command prompt like in the above picture.

      Delete
  2. cmd says 'ssh' is not recognized as an internal or external command,
    operable program or batch file.

    ReplyDelete
  3. Hi, everyone ! Help
    How can I do to transfer files from my Android phone to PC and access them in my PC. The commands instructions made on the phone and not on the PC like adb-transfer-method.
    Thank you for your help.


    ReplyDelete