Secure Shell is a network protocol, which basically means a set of rules or a set of guidelines, which tells the computer how to send data from one place to another. Telnet, FTP etc. are similar to this kind of protocols where you are sending data from your computer to a server. They are all networking protocols. However, SSH is slightly different because it is secured as the name implies.
Basically, when you are sending data over something like Telnet and FTP, you are sending it entirely in an unencrypted form. So if you type a password on one end, it goes like a plain text over the internet or over your local network. Whatever you are sending it to the server and someone in the middle can possibly see it and can possibly take your password and use it later.
But using something like SSH the chance of happening something like this is much lower and like Telnet and FTP, SSH can be used for transmitting data, transmitting commands from one place to another and also for transmitting files. It can be used anywhere in the world from one computer to another, from different platforms to different platforms. For Ex: There are SSH clients and servers available for all major modern platforms from Windows, Mac, Android, Linux, iPhone and whatever else you can probably think of.
So Lets’ see how SSH works?
Before starting the discussion, I have one question – Have you ever used SSH key? – The answer is – You must have used it while using GET or while accessing the network. But do you really know how SSH key works?
So, let me explain this with an example:-
As discussed above, we all know what is an SSH key? SSH stands for Secure Shell. It is a cryptographic network protocol. But what does Cryptographic stands for? A network protocol as a set of rules for transporting encoded data over the network, that’s why cryptographic network protocol.
Let’s see for what this SSH key is used for?
It is best used for accessing the remote servers. So when you use this SSH key you will get command line interface of the server. It’s just like sitting in front of the server which is situated far away from you.
How this SSH key is created?
Actually, SSH uses asymmetric Cipher and A Cipher is an algorithm for performing encryption or decryption. That means it is a function which performs encryption and decryption. But why we need SSH key? We need SSH key because the username and password can be stolen in the middle. The symmetrical encryption cannot be done on the remote servers. If you are not familiar with symmetrical encryption then let’s first clear this term. As SSH key uses an asymmetrical as well as the symmetrical encryption system, so we must have a knowledge of both of them.
Therefore a symmetrical encryption is simply a function which is shared with two people. That single function is capable of encrypting and decrypting data which is sent along. That means, suppose I send you “PQR” means “ZYX”, which I send you. So you also know the method to reverse the alphabet order and you can decrypt “ZYX” to “PQR”. But to perform this action you and me both should have same Cipher or same algorithm or same function which is simply reversing the alphabetical order.
Here comes a great problem because SSH key is used for accessing the server which is situated far away from you. Then the problem comes with the symmetric encryption that how you will share that function or that Cipher because even that Cipher can also be stolen and can be used by someone else in between.
So here comes a solution for symmetrical encryption and it is – Asymmetric encryption.
Asymmetric encryption uses a pair of key i.e. Public Key and Private Key. As the name suggests, a private key is a Private key which cannot be shared with anyone else. The public key is accessible to everyone. We can share it with anyone. We share this Public key with anyone who wants to access data and allow them to just encrypt their data with our Public Key. Then anything that can be encrypted via Public Key can be decrypted by the Private Key. This is very important. There are many encryption methods like RSA, DSA etc. But in whole asymmetric encryption is one function for encrypting data and for decrypting data. So we share Public Key and an encrypter and Private key as a Decrypter.
Now comes how SSH works?
As discussed earlier you have a private key and a public key and you want to access the server. So how you will perform this action? Let’s see –
From your local computer you want to access your server but before that first, you need to verify yourself. So what you do? You will pass all the public keys those are on your computer to the server. Because Public Key can be shared with anyone. So there is no problem sharing the Public Key to the server. Then on this Public Keys, server checks if it already has your Public Key registered? then if it’s found then server identifies your Public Key then verifies yourself.
After that, the server creates a new key which is a secret and then the server encrypts the key with your public key. Remember you have given the public key to the server. So with that Public Key, the server encrypts the top secret key and passes over to you again. Then because you have a private key and you can unlock this, then you need to unlock that data and you got that top to secrete and pass again over to the server. Sever knows that this is the same thing I have sent to you via your public key encrypted form and then sever says you are verified.
The SSH system creates a tunnel between your system and the server from which all the encrypted data is sent along with almost no security issue. This is how the SSH system works.
Let’s see how this system can be used?
You know we have various SSH clients on our various types of machines like our Mac OSX and Linux they have a built-in terminal. For Windows users, you can use PUTTY and for Android users can use JuiceSSH. But there is a problem with SSH key, as it is a service so it’s not available until the system starts. So that’s a great problem. If you by mistake misconfigure or turn off any kind of access then you cannot log back in. If you by mistake delete the Private Key then what’s the purpose of sending a public key to anyone. So you cannot decrypt any data. Thus these are the things you have to keep in mind while using SSH key. But at the same time, it is a great help for passing data over the network.