System Hardening
Maturity Level 1-4
System Hardening is the process of securing a system's configuration and settings to reduce IT vulnerability and the possibility of being compromised. This can be done by reducing the attack surface and attack vectors which attackers continuously try to exploit for purpose of malicious activity.
ansible
Ansible is a tool for automation of configurations and deployments. Scripts are written in yaml files as playbooks. As a Security tool we can use ansible to apply OS updates, service packs, and patches automatically; remove unnecessary drivers, file sharing, libraries, software, services, and functionality. These tasks are part of system hardening.
Installation
pip3 install ansible==2.10.4 ansible-lint==4.3.7
create an inventory file
In order to run ansible on these machinesvia SSH, we need to put them in our know-hosts list
Check the uptime of the production system with ansible
ansible -i inventory.ini
prod
-m
shell
-a "uptime"
Install a service called "ntp" with ansible on the production machine:
ansible -i inventory.ini
prod
-m
apt
-a "name=ntp state=present"
Ad-hoc commands
Which version of bash is running on my machines?
ansible -i inventory.ini
all
-m
command
-a "bash --version"
Get all parameters and vars of your inventory
ansible -i inventory.ini all -m setup
copy a file from executing machine to remote hosts
Playbooks
Check if nginx is installed
If nginx is installed, print nginx version to the terminal by using the msg module
Register an output
On the machines, using cat /etc/os-release
outputs the following data:
We can use this information and store it into a variable with register: os_release
Conditionals
Last updated