By using the public/private cryptography approach, we can do a SSH without password.
In my write-up it is for root-to-root connection. You can use it for user connections
Steps 1: At the Host Machine
- Logon to the root home directory.
- Make sure the hidden .ssh directory has the permission 700. If not execute the command
chmod 700 .ssh
- Change Directory to .ssh directory by executing the command
cd .ssh
- Generate the public-private keys using the ssh-keygen command.
# ssh-keygen -t rsa
- The resulting file id_rsa and id_rsa.pub rsa type public key
# ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host(ssh-copy-id appends the keys to the remote-host’s .ssh/authorized_key)
Step 2: At the Remote Machine, test it out
# ssh remote-host
(It should automatically login)