SSH Setup for Ansible
Ansible uses SSH for most interactions with managed servers so you need to configure and test SSH for every additional managed server you add to your inventory. The three steps below assume that you are following along with the CentOS 7 Minimal Install article and have created the SSH key as described in the Ansible Control System for ISAM article.
- Copy the ansible SSH public key to the authorized_hosts file.
- SSH to the remote system.
- Configure passwordless sudo
- Test the ansible inventory file
Copy the SSH public key
Use the ssh-copy-id command to copy the ansible user’s public key from the Ansible Control server to the new managed server.
Passwordless sudo
Passwordless sudo is accomplished either at the group or user level. To keep it simple, I configure this for the wheel group but you can do this for any group or individual users by following the instructions at https://linux-tips.com/t/passwordless-sudo/150.
If you have followed the instructions for the CentOS 7 Minimal Install, the ansible user will already be in the wheel group so the only thing you need to do is enable passwordless login for the group by commenting out the default entry and enabling the nopasswd option a few lines below:
Save the file and exit the ssh session.
Test the ansible connection.
Add the new host to your inventory file (sample.yml for the tutorials) and run the ansible ping command.
And there you have it, the server is ready for management.
Leave Comments
You must be logged in to post a comment.