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?
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!
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
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
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 🙏
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!
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: