Know about SSH!!

Aakash Shinghal
5 min readMay 23, 2021

What is SSH

SSH(Secured Shell) is a Cryptographic Network Protocol for securely accessing one computer from another. Using a number of encryption technologies, SSH provides a cryptographically secured channel over an unsecured network by using client-server architecture, connecting an SSH client application with an SSH server.SSH was designed as a replacement for Telnet

In simpler words, Secure Shell or SSH is a protocol between devices in an encrypted form. Using cryptography, any input we send in a human-readable format is encrypted for travelling over a network — where it is then unencrypted once it reaches the remote machine, such as in the diagram below.

SSH Clients

To use SSH, you will need to install an SSH client on the computer you connect from, and an SSH server on the computer you connect to.

  • MAC and Linux OS: The most popular Linux SSH client is maintained by the OpenSSH project. The OpenSSH client is included by default and can be accessed by Terminal
  • Windows: Putty can be used as SSH Client.
  • Android: Termius, JuiceSSH, and Connectbot.
  • iOS: Termius and Prompt2

Where this SSH used for

SSH can be used in many areas, few most important are listed down:

  • For login to a shell on a remote host.
  • For setting up automatic (passwordless) login to a remote server.
  • For executing a single command on a remote host

SSH Authentication Method

The two most common SSH User Authentication Methods are password-based authentication and SSH Keys based authentication

Password-Based Authentication: Default authentication method, which is a method of logging in by Username and Password. The clients safely send encrypted passwords to the server. However, passwords are a risky authentication method, as they can be stolen in the middle.

SSH Keys-based Authentication: Asymmetrically encrypted SSH public-private key pairs are a better option. This connection method uses two keys- a public key and a private key. Public key authentication allows users to log in without entering a password.

SSH Encryption Technologies

In order to secure the transmission of information, SSH uses various data encryption types during the communication between client and server machines

Symmetric Encryption Function

  • Symmetric encryption generates a single key that two machines exchange.
  • And machine uses the same key for both encryption and decryption.
  • This means, if the client wants to send “ABC to Server, then let’s say the Symmetric function encrypts it to “XYZ”.
  • Now at the receiving end, the same function will decrypt it back to “ABC”.
  • But here comes the problem, that before sharing the files and anything, first of all, that function needs to be shared in a secured manner.
  • This type of encryption is often called, “shared secret” encryption or “secret key” encryption.

Asymmetrical Encryption

  • Asymmetrical Encryption Function provided the solution to the problem posed by Symmetric Encryption Function.
  • It uses a pair of keys: a Public Key and a Private Key.
  • As the name suggests, the private keys will remain private, and will not be shared with any other system.
  • And the public key is accessible to anyone.
  • Now, let’s say System A wants to send the data to System B, then System A will need to encrypt that data with the Public Key of System B.
  • This is because anything encrypted with the public key of System B can be decrypted only by the private key of System B.
  • There are many encryption methods like RSA, DSA, but DSA has come to be seen as less secure in recent years.

Why we need this SSH

We already have a Username and Password to do remote login, then what’s the need for this SSH Key now.

  • Because Username and Password can be stolen in the middle, and hence Public key authentication (Asymmetrical Encryption) is more secure than password authentication.
  • With public-key authentication, the authenticating entity has a public key and a private key.
  • The private key is kept on the computer you log in from, while the public key is stored on the .ssh/authorized_keys file on all the computers you want to log in to.

SSH Key Working

Let’s understand how SSH Key works by understanding the connection between Client and Server:

  • The client has its own private and public keys.
  • The client will pass its public key to the Server because the public key can be shared with anyone. So, there is no problem in sharing public keys.
  • Now the server will check the presence of this public key in its .ssh/authorized_keys file.
  • Once, the server finds it, the server will create a new Key and will encrypt it with the Client’s public key.
  • Now, the client will decrypt that key with its private key and will send the secret key back to Server.
  • The server will verify the Secret key and can now trust the Client.
  • After that SSH will create a local tunnel between Client and Server for further communication.

How to Connect via SSH

To connect to a remote system using SSH, we will use the SSH command.

The most basic form of command if username of local system is same as username of remote system

ssh remote_host

If your username is different on the local system and remote system, then use the below command

ssh remote_username@remote_Host

If you want to login with an SSH private key, then use the below command

ssh -i <private_key_file_name> remote_username@remote_Host

If you want to connect and send commands as well with the connection, then use the below command

ssh -i <private_key_file_name> remote_username@remoteHost 'enter the commands'

To exit the ssh session, and return back to the local session, use the below command

exit

Drawbacks of SSH

  • SSH is a service, so it’s not available until the system starts
  • Private Key need to be secured, otherwise, the client cannot decrypt the data which was being encrypted by its public key

I hope you enjoyed reading this article, as much as I enjoyed writing it. If you like this article please let me know! But, more importantly if you disagree with this article please, please, please let me know! I made this with the hope of helping the community so if it is off it defeats the purpose! If you have a suggestion or critique please feel free to drop in any comments.

--

--