How to install Ansible and enable passwordless SSH authentication with nodes on Linux

Step1: Install Ansible:
# yum install ansible
Step2: Generate an SSH key pair on the control node:
# ssh-keygen
Go for default options for key name and location and leave 
passphrase blank.
Step3: Copy the public key to the remote nodes from control 
node.
# ssh-copy-id username@remote_host 		(Put username and hostname of remote machines)
Step4: Test SSH connection:
# ssh username@remote_host 	(You can login without entering a password)
Step5: Configure Ansible to use SSH keys:

Edit the ansible.cfg file on the control node to add the
following lines:
    makefile
    [defaults]
    host_key_checking = False
    remote_user = username
    private_key_file = /path/to/private/key
Note: Replace "username" with the appropriate username and 
"path/to/private/key" with the path to the private key
generated in step 2.
Step6: Test Ansible for all nodes added.
# ansible all -m ping 
Ansible must connect to the remote nodes and ping them 
successfully without prompting for a password.

Leave a Reply

Your email address will not be published. Required fields are marked *