Skip to content
Posted on:September 7, 2021 at 08:10 PM

Ubuntu Setup Before Running Ansible

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

  1. Login as root first and create ubuntu user
adduser ubuntu
usermod -aG sudo ubuntu
  1. Set up a Basic Firewall
ufw allow OpenSSH
ufw enable
ufw status
  1. move the ssh key that’s assigned to the root
rsync -avr --chown=ubuntu:ubuntu ~/.ssh /home/ubuntu
  1. 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

  1. Copy the ssh key to VM from my local machine
rsync -avr ~/.ssh/id.pub ubuntu@vm:~/.ssh/authorized_keys
  1. Login as ubuntu user with password
  2. 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
  1. Make the user sudo without typing password
visudo
# add this line at the bottom
ubuntu    ALL=(ALL) NOPASSWD:ALL
  1. restart the VM
reboot now

Run Ansible

Now the machines are ready to run ansible

Web Analytics