Generally, the system administrators do the operations on the multiple servers at a time. We have to provide the password for every system while logging to the system. A person generally annoys to give the login credentials every time.
The admin can generate the public and private key and the public key can be copied into the client machines. This public key in the client machine can act as the authorized credential to the server.
The public key encrypts the login credentials and the private keys decrypts the login credentials and provides access to the server machine.
• Generate the ssh key pair as follows
• System asks for the location to store the keys. By pressing enter the keys are stored in /root/.ssh directory. After that it asks for the passphrase.
• This passphrase is used in the place of the password. Enter your own passphrase two times and press enter.
• Now the key pair is successfully generated. Check the key pair in /root/.ssh.
In the above output the highlighted files are the keys. The file with the extension .pub is the public key and the other is the private key.
• Copy the public key to the client machine we can copy this file as follows by using the command ssh-copy-id -I <publickey location> <clients IP address>
From the above command the key is copying into the client machine having the ip address 192.168.1.8.
To make sure we haven't added extra keys that you weren't expecting.
• Check the client machine weather the key is copied or not.
• Now login to the client machine my client machine’s ip address is 192.168.1.8
Now we are success fully logged into the remote machine.
After doing all this configuration a doubt may raise to you that is here we are providing a pass phrase then what is the difference. This is similar to the normal login right!
It is different because during the configuration there is no need to give the passphrase. But for the minimal security we are providing the passphrase.