The commands below will allow configuring password-less SSH access from one Linux server to another using a private key.
Generate SSH Key from client computer. By default, ssh-keygen will create a 2048-bit RSA key pair. It is secure enough for most scenarios. You may optionally pass in the -b 4096 flag to create a larger 4096-bit key.
ssh-keygen
After entering the command, you should see the following prompt:
Generating public/private rsa key pair.
Enter file in which to save the key (/your_home/.ssh/id_rsa):
Press ENTER to save the key pair into the .ssh/ subdirectory in your home directory, or specify an alternate path.
Enter passphrase (empty for no passphrase):
Once key creation is successful, you will see similar output like one below. It will create both private and public (.pub) key.
Your identification has been saved in /your_home/.ssh/id_rsa.
Your public key has been saved in /your_home/.ssh/id_rsa.pub.
The key fingerprint is:
a7:85:24:5b:5e:21:56:b6:d1:e4:2a:44:34:b5:e7:24 username@remote_host
The key's randomart image is:
+--[ RSA 2048]----+
| ..o |
| E o= . |
| o. o |
| .. |
| ..S |
| o o. |
| =o.+. |
|. =++.. |
|o=++. |
+-----------------+
Copy the SSH key (.pub) to the server you wish to access password-less.
ssh-copy-id -i /path/to_file/ssh_key.pub root@YOUR_SERVER_IP
Try
ssh 'root@YOUR_SERVER_IP'