The Concept of SSH

Reading Time: 3 minutes

Hello readers, if you are new to this term ssh, then this is the blog for you. I’ll cover SSH from basic, laying down its importance and will show you how to configure SSH for remotely accessing a Linux server.

What is SSH and why it is required?

SSH stands for Secure Shell. It is a communication protocol, which helps us in communication with other devices over a network, just like HTTP does. So what’s the difference? It is known for sending encrypted data over the network so that it can be prevented from unauthorized access. It runs on port number 22 by default. SSH first ensures the authenticity of the client and then build a pipeline between the SSH client and the server. Data transmitted through this pipeline is encrypted by using the concept of Asymmetric Data Encryption. To know more about asymmetric encryption, you can refer to this video on Asymmetric Encryption.

When to use SSH?

Following are the use cases for using SSH.

  1. For transferring some data securely over the network.
  2. Get access to a remote server.

Configuring SSH on Linux server

As we know that we can use SSH to get access of a remote server, I’ll show you how to configure SSH on a Linux machine. To excess any remote Linux machine through SSH, it must have SSHD, that is open ssh daemon which allows the remote machine to act as an SSH server.

Following is the command to install SSHD:

sudo apt-get install openssh-server

This will allows the machine to listen to ssh connections. Now we can get access of that remote machine in our terminal by the following command:

ssh <userid>@<IPaddress>

In the above command, the userid signifies the alias of remote machine andIPaddress signifies the IP address of remote server.

After adding this, you will be prompted for allowing your client machine to get access to the remote server. Enter yes to add the server to your list of known hosts stored at ~/.ssh/known_hosts . Then it will ask for the password of that system. As passwords can be easily stolen or can be accessed by the bruteforce attack, we want SSH authentication for which we need to have a pair of public and private key.

SSH key pair generation

To generate a pair of rsa keys, the command is :


The keys will be generated as follows:

  • Private key: ~/.ssh/id_rsa
  • Public key: ~/.ssh/

These generated keys will be encrypted using RSA cypher method. To use any other cypher technique, you need to use -t flag as follows:

ssh-keygen -t dsa

Now for SSH authentication, we need to add our public key to remote machine’s authorized_hosts file. For this, we will use scp command which means secure copy.

scp ~/.ssh/ userid@IPaddress:~/.ssh/authorized_keys

This will successfully configure the SSH and now you will have the access to the remote machine through your SSH client which is your CLI.

After going through the contents, now you’ll be familiar with the concept of SSH, why it is used and how to configure it for accessing a remote server. Still, if you have any queries, feel free to contact me at


Written by 

Yatharth Sharma is a Software Trainee at Knoldus Software LLP. He has done MCA from Bharati Vidyapeeth Institute of Computer Application and Management, Paschim Vihar. He has a decent knowledge of C, C++, Java and currently working on DevOps technologies/tools like Ansible, Jenkins, Docker, Kubernetes. Apart from programming, he loves listening to rap music.

Leave a Reply

Knoldus Pune Careers - Hiring Freshers
