diff options
Diffstat (limited to 'tasks')
| -rw-r--r-- | tasks/main.yml | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tasks/main.yml b/tasks/main.yml index 32ae5b1..4520020 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,10 +1,25 @@ - name: Disable PasswordAuthentication + vars: + sshd_config_path: /etc/ssh/sshd_config tags: - ssh block: + - name: Check if sshd_config exists + ansible.buildin.stat: + path: '{{ sshd_config_path }}' + register: sshd_config_file + + - name: Copy initial sshd config + when: not sshd_config_file.stat.exists + ansible.builtin.copy: + src: /usr/etc/ssh/sshd_config + dest: '{{ sshd_config_path }}' + remote_src: true + mode: '640' + - name: Disable PasswordAuthentication in sshd config ansible.builtin.lineinfile: - path: /etc/ssh/sshd_config + path: '{{ sshd_config_path }}' regexp: "^[#]?\\s?PasswordAuthentication" line: "PasswordAuthentication no" register: disable_passwds |
