24 lines
721 B
YAML
24 lines
721 B
YAML
---
|
|
- name: Konfiguracja SSH (blokada pustych haseł)
|
|
hosts: all
|
|
gather_facts: true
|
|
|
|
tasks:
|
|
- name: Zablokuj logowanie na puste hasła (PermitEmptyPasswords no)
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/ssh/sshd_config
|
|
# Szuka linii zaczynającej się od PermitEmptyPasswords (również zakomentowanej)
|
|
regexp: '(?i)^\s*#?\s*PermitEmptyPasswords'
|
|
line: 'PermitEmptyPasswords no'
|
|
state: present
|
|
backup: yes
|
|
# Sprawdza poprawność pliku przed zapisem, aby nie zepsuć SSH
|
|
validate: '/usr/sbin/sshd -t -f %s'
|
|
notify: Restart SSH
|
|
|
|
handlers:
|
|
- name: Restart SSH
|
|
ansible.builtin.service:
|
|
name: ssh
|
|
state: restarted
|