Files
skato-ansible/roles/init-server/tasks/harden.yml

18 lines
570 B
YAML

#SPDX-License-Identifier: MIT-0
---
# tasks file for roles/init-vps
- name: Checking whether administrative login used
when: ansible_user not in (admins | map(attribute="username") | list) and ansible_user != "root"
ansible.builtin.fail:
msg: Must use administrative user for subsequent tasks
- name: Hardening SSH service
ansible.builtin.copy:
src: sshd_config.d/harden.conf
dest: /etc/ssh/sshd_config.d/harden.conf
owner: root
group: root
mode: "644"
force: true
backup: true
validate: 'sshd -t -f %s'
register: ssh_hardened