Ubuntu Setup Before Running Ansible
Digital Ocean
Right after creating the droplet, they don’t have an user account to login other than root. So you’d have to create an user and give ssh access
- Login as root first and create
ubuntu
useradduser ubuntu usermod -aG sudo ubuntu
- Set up a Basic Firewall
ufw allow OpenSSH ufw enable ufw status
- move the ssh key that’s assigned to the root
rsync -avr --chown=ubuntu:ubuntu ~/.ssh /home/ubuntu
- Make the user sudo without typing password
visudo # add this line at the bottom ubuntu ALL=(ALL) NOPASSWD:ALL
VMware
Right after creating the VM, they only allow ssh login with password. So you’d have to change sshd config to login with your ssh key
- Copy the ssh key to VM from my local machine
rsync -avr ~/.ssh/id.pub [email protected]:~/.ssh/authorized_keys
- Login as
ubuntu
user with password - Sudo to root and change sshd_config
sudo su - nano /etc/ssh/sshd_config # change these settings ChallengeResponseAuthentication no PasswordAuthentication no UsePAM no PermitRootLogin no PermitRootLogin prohibit-password
- Make the user sudo without typing password
visudo # add this line at the bottom ubuntu ALL=(ALL) NOPASSWD:ALL
- restart the VM
reboot now
Run Ansible
Now the machines are ready to run ansible
COMMENTS