You can create a password less connection between two Linux box using RSA authentication. Before moving ahead with the steps to do so let us get to know RSA in brief.
RSA and DSA are used as an algorithm for public-key encryption
- RSA keys have minimum key length of 768 bits and the default length is 2048 bit.The key length of DSA is limited to 1024 bit so one can generate stronger RSA keys than DSA keys.
- DSA encryption is faster as compared to RSA.
- RSA can be used for both encryption and signing whereas DSA can only be used for signing.
- RSA can be used with ssh v1 and v2 whereas DSA can only be used with v2
Server IP: 192.168.0.110
Client IP: 192.168.0.100
This command will generate a private(id_rsa) and a public(id_rsa.pub) key.
NOTE: Make sure you give a blank password when prompted as shown with blue color below
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
The key’s randomart image is:
+–[ RSA 2048]—-+
|ooo . |
|B. + . |
|*++ . |
|== . . |
|..o . S |
| . . . o |
| o . o E |
| . . . |
| ..o. |
Now we need to copy the public key to the remote machine between which you want the secure shell connection.
# scp /root/.ssh/id_rsa.pub 192.168.0.100:/root/.ssh/authorized_keys
# chmod 600 /root/.ssh/authorized_keys
# chmod 700 /root/.ssh
Now restart the ssh services on the server and client machines
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
Now try to connect your client server, you should be able to connect without password prompt
# ssh 192.168.0.100
# ssh-keygen -p