Secure Shell
What is Secure Shell?
SSH, also known as Secure Shell or Secure Socket Shell, is a network protocol that allows users to access a remote server or a device.
SSH uses keys or password to authenticate the connection.
SSH is preinstalled in almost every linux distro.
In this blog, I will be skipping the installation and steps like port forwarding as the primary aim of this blog is to explain how to ”use” SSH.
Usage
Server Side
To start ssh on the server side, ie, the following command should be executed on the device you are trying to ssh into.
The first command generates a key and the second command starts the ssh daemon.
Issue
While trying to execute this command, you may face an error asking you to generate a key even after you have generated it.
If you are on linux, try running this command to fix it or try running the previous command with elevated privileges.
Client Side
To connect to the server, Run this command.
Config
Instead of typing the ip-address and username everytime a config file can be set up in the .ssh dir.
Encryption
By default, the algorithm used to encrypt the keys is RSA.
You can choose an algorithm of your choice by executing the following command.
Security
Instead of typing in the password everytime, a key can be used to login to the server.
To generate the key, run the
command.
ssh-keygen
Two files will be generated in the .ssh folder. The file with .pub extension is the public key and the other is the private key.
The public key generated has to be copied to the authorized_keys file in the server .ssh dir.
This can be done manually but copying and pasting the key or by executing the following command.
After this you wouldn’t be prompted to enter the password when you try to login.