Dr. Maik Ro
banner
maikroservice.com
Dr. Maik Ro
@maikroservice.com
💜-Team Hacker
Training the next generation of purple team hackers
(he/him)
https://maikroservice.com/email
Dr. Maik Ro (@maikroservice.com)
How to rock IT automation with ansible 🤘🦾:
tbsky.app
December 3, 2025 at 8:00 AM
WOHOOOOO IT WORKED WE ARE MAGICIANS! 🪄🦄

Well done friends, in the next post we shall do the same on multiple machines at the same time 💜

Cant wait to talk to you again!
December 3, 2025 at 7:46 AM
It has an associated IP address, a username that should be used for the ssh connection and the private key needed to initiate the connection

with that out of the way we can run the command from earlier:

ansible -i hosts.yml infrastructure -a 'ping 192.168.188.1 -c 1'
December 3, 2025 at 7:46 AM
What do we see here?!

First all the machines are collected by a self-defined metagroup - “infrastructure”.

now a list of all the hosts inside this group follows, in this example we will only have one for now - debian
December 3, 2025 at 7:46 AM
WAIT - STOP - HOLD ON

what is inside the hosts.yml and what is a yml in the first place?

a .yml file is a yaml (Yet Another Markup Language) file
December 3, 2025 at 7:46 AM
but how do we execute the commands now?

you use ansible 💜

like so:

ansible -i hosts.yml infrastructure -a 'ping 192.168.188.1 -c 1'
December 3, 2025 at 7:46 AM
fear not - that is totally expected - your key is well “hidden” in the authorized keys - open that one and find out:

aha - ok that looks like the correct key with the correct username at the end 😌
December 3, 2025 at 7:46 AM
GREAT!

can we check if the key is really there?

sure!

but um… this does not look like it is there?
December 3, 2025 at 7:46 AM
you type:

ssh-copy-id -i <location_of_your_ssh_key> username@controlled-machine

press enter and then you need to enter the password for the controlled-machine user

if all goes well you see something similar to the following image:
December 3, 2025 at 7:46 AM
wonderful - now two options exist

1. you copy the public ssh key to the machine via copy/paste

2. you use ssh-copy-id

We shall use 2. today, because it is freaking cool!
December 3, 2025 at 7:46 AM
now generate a private key on your host machine with

ssh-keygen -b 4096

make sure to enter the correct location and add a passkey if you care about security 🙏
December 3, 2025 at 7:46 AM
if you are lucky it is already running - if not install it via:

sudo apt-get install openssh-server
December 3, 2025 at 7:46 AM
cool cool cool - what now?

now you need to identify how you can connect to the controlled machine - e.g. via ssh if it is linux

that means ssh needs to run on the controlled machine - check via:

systemctl status ssh
December 3, 2025 at 7:46 AM
smash that y button and the enter key right afterwards

and then wait until the install is finished ⏳ → ⌛️
December 3, 2025 at 7:46 AM
First, install ansible on your host machine via:

sudo apt-get install ansible

(if your host is debian/ubuntu based)
December 3, 2025 at 7:35 AM
and the best part?

you do _NOT_ have to install it on the client systems, only on your host / the controlling node!

Ok great, but how do we start ➡️ 🏁
December 3, 2025 at 7:31 AM
Well, it was not made for patching but who am I to judge if you need an automated solution and this is all you have?! 🧑🏻‍⚖️❌

ansible is basically your go to shop 🏪 for running commands on existing machines

it logs in for you, runs commands for you and gives you feedback if it all worked out
December 3, 2025 at 7:31 AM
In case you dont know what all of these tools are - they are great 🤪

We shall start with ansible - the ez pz 🍋 patch engine
December 3, 2025 at 7:31 AM
You could use your “well prepared automation setup” that features:

🤖 ansible
🦾 packer
🧞‍♀️ terraform
🔐 vault

WAYYYY cooler, right?
RIGHT?
December 3, 2025 at 7:31 AM
well… You could:
🔍 search for all the hostnames,
🤝 gather possible login options
🕵️ find username/password combinations
🤪 go mad because it’s taking too long

OR!
December 3, 2025 at 7:31 AM
Imagine the following situation - you have worked in IT for a while

and some virtual machines + the services running on them need to be updated

What do you do?
December 3, 2025 at 7:30 AM
Ulallaaaaaa you had me at client-side only 😇🥰
November 28, 2025 at 5:06 PM