diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2022-10-14 15:24:28 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2022-10-14 15:24:28 +0200 |
| commit | c9bc611a128842b5dc7ae713f7bad4bfb2aef606 (patch) | |
| tree | c8802e0b23daeae5f64a58ed9b2bd05f3b56ac71 | |
| parent | 9fb87407c6c539683249a5fc52603fee86ef286a (diff) | |
| download | sshd_disable_passwd_login-c9bc611a128842b5dc7ae713f7bad4bfb2aef606.tar.gz sshd_disable_passwd_login-c9bc611a128842b5dc7ae713f7bad4bfb2aef606.zip | |
try to copy initial sshd_config from /usr
This is needed on OpenSUSE Tumbleweed ans has no effect if sshd_config
is already present.
| -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 |
