skylab
/
skylab-ansible
Archived
2
0
Fork 0

Consolidate ssh config tasks

This commit is contained in:
Ethan Paul 2021-11-05 21:40:20 -04:00
parent 9e0c0505b3
commit 6819e6b4cb
No known key found for this signature in database
GPG Key ID: 6A337337DF6B5B1A
1 changed files with 18 additions and 27 deletions

View File

@ -120,37 +120,28 @@
name: sshd
state: restarted
tasks:
- name: Disable root auth
- name: Configure SSH authentication settings
become: true
ansible.builtin.replace:
path: /etc/ssh/sshd_config
regexp: "^.*PermitRootLogin (yes|no).*$"
replace: "PermitRootLogin no"
notify: [restart-sshd]
- name: Disable password auth
become: true
ansible.builtin.replace:
path: /etc/ssh/sshd_config
regexp: "^.*PasswordAuthentication (yes|no).*$"
replace: "PasswordAuthentication no"
notify: [restart-sshd]
- name: Disable challenge response auth
become: true
ansible.builtin.replace:
path: /etc/ssh/sshd_config
regexp: "^.*ChallengeResponseAuthentication (yes|no).*$"
replace: "ChallengeResponseAuthentication no"
notify: [restart-sshd]
- name: Disable GSSAPI auth
become: true
ansible.builtin.replace:
path: /etc/ssh/sshd_config
regexp: "^.*GSSAPIAuthentication (yes|no).*$"
replace: "GSSAPIAuthentication no"
regexp: "{{ item.regex }}"
replace: "{{ item.value }}"
notify: [restart-sshd]
loop:
- name: disable root login
regex: "^.*PermitRootLogin (yes|no).*$"
value: PermitRootLogin no
- name: disable password auth
regex: "^.*PasswordAuthentication (yes|no).*$"
value: PasswordAuthentication no
- name: disable challenge response auth
regex: "^.*ChallengeResponseAuthentication (yes|no).*$"
value: ChallengeResponseAuthentication no
- name: disable GSSAPI auth
regex: "^.*GSSAPIAuthentication (yes|no).*$"
value: GSSAPIAuthentication no
loop_control:
label: "{{ item.name }}"
- name: Disable dynamic MOTD on debian systems
when: ansible_os_family == "Debian"