aboutsummaryrefslogtreecommitdiff
path: root/tasks/main.yml
blob: 0ed3243ff60b3e0f1e5d4008bc2770a2a018e690 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
---
- name: Disable PasswordAuthentication
  tags:
    - ssh
  block:
    - name: Disable PasswordAuthentication in sshd config
      lineinfile:
        path: /etc/ssh/sshd_config
        regexp: "^[#]?\\s?PasswordAuthentication"
        line: "PasswordAuthentication no"
      register: disable_passwds

    - name: Restart service sshd
      when: disable_passwds.changed
      ansible.builtin.service:
        name: sshd
        state: restarted