Friday, June 4, 2021

To enable key for connect password less node from ansible.

now will generate key for password less authentication from ansible controller to node1
create ansible user on node1 
useradd ansible 

sudo ansible
cd ~
ls -l
ls -la
mkdir .ssh/
vi .ssh/authorized_keys

now goto contoller
ssh-keygen
cat /root/.ssh/id_rsa.pub
copy the code key and go back to node1 
paste there and save file
chmod -R 700 .ssh/ on node1 

not try to connect node1 from controller. it should connect without password.

now edit hosts files under /etc/ansible/hosts on cotroller machine

add the entry of host ip

also edit the /etc/ansible/ansible.cfg file for remote_user= ansible

now try ansible all -m ping 

ansible all -a "uptime"

No comments: