Ssh between ansible control node with that of target
•
0 likes•26 views
The document outlines the steps to set up SSH key-based authentication between an Ansible control node and two target nodes to enable Ansible to configure the target nodes without passwords. It involves generating public/private key pairs on the control node, adding the public key to each target node's authorized_keys file, and restricting password logins for security.
1 of 4
Download to read offline
More Related Content
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