How to set up password-less login on RHEL-based Linux distributions such as CentOS, Fedora using ssh keys to connect to remote Linux servers without entering a password.
Password-less login with SSH keys will increase the trust between two Linux servers for easy communicate with each other.
In this example, we will set up SSH password-less automatic login from server 192.168.100.12 as user itmaddy to 192.168.100.11 with user maddy.
Step 1: Create Authentication SSH-Keygen Keys on – (192.168.100.12)
First need to login into server 192.168.100.12 with user itmaddy and generate a pair of public keys using the following command.
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/itmaddy/.ssh/id_rsa): [Press enter key]
Created directory ‘/home/itmaddy/.ssh’.
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Press enter key]
Your identification has been saved in /home/itmaddy/.ssh/id_rsa.
Your public key has been saved in /home/itmaddy/.ssh/id_rsa.pub.
The key fingerprint is:
5f:2d:30:00:8a:d1:4b:99:b3:b0:f9:08:11:c1:ed:d1 itmaddy@itmaddy.com
The key’s randomart image is:
+–[ RSA 2048]—-+
| ..oooE.++|
| o. o.o |
| .. . |
| o . . o|
| S . . + |
| . . . o|
| . o o ..|
| + + |
| +. |
+—————–+
Step 2: Upload the SSH Key into – 192.168.100.11
Then Use SSH from server 192.168.100.12 and need to upload a new generated public key (id_rsa.pub) on server 192.168.100.11 under maddy‘s .ssh directory as a file name authorized_keys.
$ ssh-copy-id maddy@192.168.100.11
Step 3: Test the SSH Passwordless Login from the 192.168.100.12
Now you can log into 192.168.100.11 as maddy user from server 192.168.100.12 as a itmaddy user without a password.
$ ssh maddy@192.168.100.11