added ssh banner playbook

This commit is contained in:
Bryan Joshua Pedini 2022-09-11 19:11:31 +02:00
parent e311127a98
commit cbc8b517e8
4 changed files with 37 additions and 0 deletions

6
sshbanner-bjphoster.yml Normal file
View File

@ -0,0 +1,6 @@
---
- hosts: all
become: true
tasks:
- import_tasks: tasks/debian-general/sshbanner-bjphoster.yml
- import_tasks: tasks/debian-general/sshbanner.yml

View File

@ -0,0 +1,5 @@
---
- name: Restart SSH service to apply new rules
ansible.builtin.systemd:
name: ssh
state: restarted

View File

@ -0,0 +1,19 @@
---
- name: Ensure /etc/banner is populated with BJPHoster Network
ansible.builtin.copy:
dest: /etc/banner
content: |
|--------------------------------------|
| This is a private system managed |
| by the BJPHoster Private Network. |
| |
| Unless otherwise authorized you are |
| to leave this virtual premise |
| immediately, otherwise this will be |
| considered a security breach attempt |
| and will be reported to the |
| competent authorities and persecuted |
| to the extent permitted by the |
| applicable law of the country where |
| these systems reside. |
|--------------------------------------|

View File

@ -0,0 +1,7 @@
---
- name: Ensure SSH banner is uncommented and right path in /etc/ssh/sshd_config
ansible.builtin.lineinfile:
line: "Banner /etc/banner"
path: /etc/ssh/sshd_config
regexp: '^#\s*Banner.*$'
- import_tasks: restart-ssh-service.yml