Password less or Key based authentication is when you don’t need to provide the password to login to another system, instead password you provide the private key. In passwordless authentication you don’t need to worry about remembering / managing your password but still you need to keep you private key safe.
Following are the steps you need to perform to setup password less authentication on Linux systems
Create a Public and Private key pair
you can use the following command to create a public and private key pair.
$ ssh-keygen -t rsa -b 4096 -C “admin1”
Here -t is to tell which encryption algorithm to use -b specify the length of key file in bytes -C is for comment I generally specify the name of the user.
Copy Public Key using ssh-copy-id
Once the public and private keys are created you need to copy the public key which usually ends with .pub extention to the ~/.ssh/authorized_keys file of other server with following command.
$ ssh-copy-id -i .ssh/id_rsa.pub firstname.lastname@example.org
After copying the public key you will be able to login to another server without using the password.
If you give custom name to your ssh keys other that default names (id_rsa.pub / id_rsa) then use following command to login
$ ssh -i /path/to/private-key-file/private-key-name email@example.com
That’s it you have setup password less authentication and keep your private key secure.