To set up a passwordless SSH login in Linux all you need to do is to generate a public authentication key and append it to the remote hosts ~/.ssh/authorized_keys file.
The following steps will describe the process for configuring passwordless SSH login:
1. Check for existing SSH key pair
Before generating a new SSH key pair first check if you already have an SSH key on your client machine because you don’t want to overwrite your existing keys
Command: ls -al ~/.ssh/id_*.pub
2. Generate a new SSH key pair
The following command will generate a new 2048 bits SSH key pair with your email address as a comment:
ssh-keygen -t rsa -b 2048 -C “your_email@domain.com”
Note: Enter your mail ID in place of “your_email@domain.com”
Press Enter to accept the default file location and file name:
Output: Enter the file in which to save the key (/home/yourusername/.ssh/id_rsa)
Next, the ssh-keygen tool will ask you to type a secure passphrase. Whether you want to use a passphrase it’s up to you, if you choose to use a passphrase you will get an extra layer of security. In most cases, developers and system administrators use SSH without a passphrase because they are useful for fully automated processes. If you don’t want to use a passphrase just press Enter.
Output

To be sure that the SSH keys are generated you can list your new private and public keys by running the following command
Run: ls ~/.ssh/id_*Output: /home/yourusername/.ssh/id_rsa /home/yourusername/.ssh/id_rsa.pub

3. Copy the public key
Now that you have generated an SSH key pair, in order to be able to login to your server without a password you need to copy the public key to the server you want to manage
ssh-copy-id remote_username@server_ip_address
Note: Change the remote_username and server_ip_address where you want to push this key.
You will be prompted to enter the remote_username password, Enter the password to continue:

4. Now change the private key into .pem format
Follow the below steps to convert Privatekey into .pem .
Launch PuTTYgen.
- Click on the Load button under the “Actions” section.
- In the file dialog, change the file type to All Files (*.*) since PuTTYgen typically saves keys in .ppk format.
- Navigate and select your private key file (.ppk or other formats).
- After loading the private key, ensure the key type is correct.
- Click on Conversions in the top menu and choose Export OpenSSH key (force new file format).
- Save the file with the .pem extension in your desired location.
5. Login to your server using SSH keys
After completing the steps above you should be able to login to the remote server without being prompted for a password.
To test it just try to log in to your server via SSH:
ssh -i <key.pem> remote_username@server_ip_address
