Consolidate ssh config tasks
This commit is contained in:
		@@ -120,37 +120,28 @@
 | 
				
			|||||||
        name: sshd
 | 
					        name: sshd
 | 
				
			||||||
        state: restarted
 | 
					        state: restarted
 | 
				
			||||||
  tasks:
 | 
					  tasks:
 | 
				
			||||||
    - name: Disable root auth
 | 
					    - name: Configure SSH authentication settings
 | 
				
			||||||
      become: true
 | 
					      become: true
 | 
				
			||||||
      ansible.builtin.replace:
 | 
					      ansible.builtin.replace:
 | 
				
			||||||
        path: /etc/ssh/sshd_config
 | 
					        path: /etc/ssh/sshd_config
 | 
				
			||||||
        regexp: "^.*PermitRootLogin (yes|no).*$"
 | 
					        regexp: "{{ item.regex }}"
 | 
				
			||||||
        replace: "PermitRootLogin no"
 | 
					        replace: "{{ item.value }}"
 | 
				
			||||||
      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"
 | 
					 | 
				
			||||||
      notify: [restart-sshd]
 | 
					      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
 | 
					    - name: Disable dynamic MOTD on debian systems
 | 
				
			||||||
      when: ansible_os_family == "Debian"
 | 
					      when: ansible_os_family == "Debian"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user