- name: Disable the root account
user:
name: root
password: '!'
password_lock: yes
notify:
- Disable SSH login for root
- Disable SSH password authentication
- name: Disable SSH login for root
replace:
path: /etc/ssh/sshd_config
regexp: "^.*PermitRootLogin.*$"
replace: "PermitRootLogin no"
- Reload SSH service
- name: Disable SSH password authentication
regexp: "^.*PasswordAuthentication.*$"
replace: "PasswordAuthentication no"
- name: Reload SSH service
systemd:
name: ssh
state: reloaded
- name: Enable and restart iptables
name: netfilter-persistent
state: restarted