Ssh between ansible control node with that of target
1. Objective
As a DevOps Engineer I want to set up Configuration Management
System using Ansible. I have Two Target Machine and One Ansible
Control node.
I want to setup SSH between Ansible Control node with that of Target
Node
3. 1. Generate your keys (Ansible Control Node // It wants to access target)
//Login to Ansible Node
sudo su
// generate the keys
ssh-keygen -t rsa
//i.e it will generate 2 files id_rsa.pub(public key) and id_rsa(private key) at location /root/.ssh/
2. Create a file "authorized_keys" at the root user's .ssh directory .
Change the .ssh directory mode to 700(executable) and authorized_keys file mode 600(read & write)
//Login to Target Node
sudo su
//create a file named "authorized_keys" at /root/.ssh/ (if not present already)
touch authorized_keys
//Change the /root/.ssh mode to 700 and authorized_keys file mode to 600
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys/
4. 3. Add the Ansible public key to the "authorized_keys"of the Target Node
// Login to the target node
sudo su
vi /root/.ssh/authorized_keys
//move to end , press enter copy the public key and paste here, save exit
4. Optional(restrict the password authentication)
//Login to Target Node
sudo su
vi /etc/ssh/sshd_config
//change the line PasswordAuthentication yes to no