aboutsummaryrefslogtreecommitdiff
path: root/tasks/main.yml
blob: 32ae5b186e49d4a5dd6137a66bd469780ab38368 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- name: Disable PasswordAuthentication
  tags:
    - ssh
  block:
    - name: Disable PasswordAuthentication in sshd config
      ansible.builtin.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