Accessing Termux from Putty

themountain
3 min readSep 1, 2018

--

There are like hundreds of posts on how to setup your SSH server and client so that you can take a remote of it. But I never understood the whole thing after following every single post like that. Finally i got the whole thing just last week and decided to create a post about it. Here i am just going to try to explain how SSH protocol works and what you need to get your SSH server up and running. We will also see how to connect to your SSH server from your client by creating a Public and Private Keys.

Before starting with the whole installation process let’s first understand how SSH works.

SSH also referred to as Secure shell is a secure remote login protocol. There are different implementation of the protocol which you might have heard of like Putty.

So, how does the server know that the client that it is allowing to connect is an authorized one or not?

SSH employs Public Key Cryptography to ensure that only authorized clients can create a secure connection with the server. We will see it using Bob and Alice’s example. Bob wants to send a message to Alice but he does not want it to share it with anyone else. So, Bob(Server) takes one alphanumeric string from Alice(Client) which will be Alice’s public key to encrypt his message and then sends it to Alice. Alice has her Private Key using which she decrypts the message and after that they can connect with each other share messages using the same set of Public and Private keys.

Same way a server stores all authorized clients public keys in ~/.ssh/authorized_keys and private keys will be on the client side to decrypt the messages.

Now, I will show you how to install SSH server on Termux a popular terminal emulator app for Android. And then we will connect to Termux from Putty.

For this session every line starting with $ is a command which you need to execute on your device. Don’t write the first $ sign as it is depicting the shell.

  1. Installing open-ssh

$apt install openssh

Once openssh is installed you can start your ssh server by running :

$sshd

Your ssh server has started. By default SSH port number is 22 but termux starts it on Port 8022.

Termux does not have a user login functionality for SSH. So, for everyone wanting to connect to it through SSH has to do it with Public Cryptographic key method. So, to create a connection between your PC and Laptop make sure that both are on same network.

Now generate a set of Public and Private keys on your Termux by executing:

$ssh-keygen

A confirmation prompt will be displayed with default key names and full path where it will be stored. If you wish to change path or name of the file than just enter new Path or name and press enter.

By default your files would have been stored in the ~/.ssh directory. You can copy the contents of id_rsa.pub (Public key) file to ~/.ssh/authorized_keys file and copy the id_rsa file (Private key) to your laptop.

Open Putty and go to Connection>SSH>Auth. Browse for your private key (id_rsa) and click open. Enter your phone’s IP address and enter port number as 8022. You can also save the session if you do not want to repeat the process every time. Click Enter and you are connected to your phone.

If you face any issues while following this do let me know in the comments.

--

--