SSH - Password less

SSH - Password less

Password-protected choices can be difficult to remember and uncomfortable for users. You can be in a situation where you have to input your password regularly.

Passwordless SSH has a few advantages:

  1. Login is simple and non-interactive.

  2. Users do not have to type the password for each new session.

  3. It is more secure than passwords since it uses public-private key cryptography.

  4. More dependable

  5. Improved authentication and authorization administration A suitable solution for both small and large infrastructures.

  6. Simple to construct and maintain

Steps To Setup Password-less SSH :

  1. Run the below command on the local machine,
ssh-keygen

Following the execution of the preceding command, it will prompt for a location to store the private key. If no location is specified, the default location will be used. If a key already exists, you will be prompted to overwrite it. You must then provide a passcode for the key. It is optional and can be left blank. Your Public and Private keys will now be generated and saved in their appropriate locations. If you do not specify a place, the default location will be
Private key

/home/<userdirectory>/.ssh/id_rsa

Public key

/home/user/.ssh/id_rsa.pub
  1. Change the permission of the file :

    The private key's file permissions should be set to 600. To alter its permission, we shall use the chmod command.

    To alter the permissions, first, move the directory to the private key directory and then run the following command -

     cd ~/.ssh
     chmod 600 id_rsa
    
  2. Configuring the server :
    Now we must set up the server to utilize our private key for authentication.

    To do so, enter the following command -

     ssh-copy-id username@IP-address
    
  3. Establishing a connection with the client:

    To do so, use the following command – We are now prepared to connect to a remote server using SSH without a password.

    Use the following command to accomplish this =-

     ssh user@IP