This repo provides a simple way to set up OpenSSH and configure public keys on multiple Ubuntu machines to prepare them for Ansible automation.
✅ Installs OpenSSH on target Ubuntu machines.
✅ Adds your public SSH keys for seamless Ansible access.
✅ Includes a sample hosts.txt file for Ansible inventory.
To get started, clone this repository to your local machine:
git clone https://github.com/michaelbolanos/ansible-install.git
cd ansible-install/scriptsEdit the hosts.txt file to include the IP addresses or hostnames of the machines you want to manage with Ansible:
192.168.1.100
192.168.1.101
192.168.1.102
Run the following command on each Ubuntu machine to install OpenSSH.
curl -sSL https://raw.githubusercontent.com/michaelbolanos/ansible-install/main/scripts/install_ssh.sh | bashwget -qO- https://raw.githubusercontent.com/michaelbolanos/ansible-install/main/scripts/install_ssh.sh | bashTo enable passwordless SSH authentication, use the provided ssh-keys.sh script. Run this from your control machine:
bash ssh-keys.shThis script will:
# Copy SSH public key to each host in hosts.txt
while read -r host; do
ssh-copy-id -i ~/.ssh/id_rsa.pub "ubuntu@$host"
done < hosts.txt- Copies your SSH public key to each host listed in
hosts.txt - Ensures secure key-based authentication
Once keys are copied, test SSH access to the remote machines:
If login works without a password prompt, you're ready to use Ansible! 🎉
Now that SSH is configured, install Ansible and begin automating your infrastructure.
sudo apt update && sudo apt install -y ansibleYou can now create an Ansible inventory file and start managing your machines