In this post will show you how to create a password-less connection between two Unix machine. For the same as a first step you have to generate a public and private key using ssh-keygen command on a source machine and then copy that key to the remote host using ssh-copy-id command, where you will be logging to the remote host without password from a source machine. But, I will not prefer you to use a password-less login in production environment, but still you can use if it’s really required by without sharing the root password of the source machine.
Normally this password-less connection works by using a public key authentication method which will allow you to login to the remote host without a password using ssh protocol. So here I have used ‘redhatlinuxsrv’ as a source machine and ‘redhatlinuxcli’ as a remote host where you will be creating a password-less connection from ‘redhatlinuxsrv’ to ‘redhatlinuxcli’ using a public key authentication method.
Step 1: Create rsa key in ‘redhatlinuxsrv’ source host
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
Now successfully you have created the rsa key.
Step 2: Copy the key to remote host ‘redhatlinuxcli’
user@redhatlinuxsrv$ ssh-copy-id –i ~/.ssh/id_rsa.pub root@redhatlinuxcli
Now try logging into the machine with “ssh ‘root@redhatlinuxcli‘” and check in:
to make sure we haven’t added extra keys that you weren’t expecting.
Step 3: Login to remote host ‘redhatlinuxcli’ without password
user@redhatlinuxsrv$ ssh root@redhatlinuxcli
Last login: Sat Sep 19 11:34:00 2015 from 192.168.1.1
If you find this post is useful/helpful, please follow, like and share. Thank you for visiting my blog!!!