31 lines
789 B
YAML
31 lines
789 B
YAML
---
|
|
- name: Diagnose and fix SSH on localhost
|
|
hosts: localhost
|
|
become: yes
|
|
tasks:
|
|
- name: Check sshd service status
|
|
ansible.builtin.command: systemctl status sshd --no-pager
|
|
register: sshd_status
|
|
ignore_errors: yes
|
|
|
|
- name: Show sshd status
|
|
ansible.builtin.debug:
|
|
var: sshd_status.stdout_lines
|
|
|
|
- name: Check listening ports
|
|
ansible.builtin.shell: ss -tlnp | grep -E ':22|:2222'
|
|
register: ports
|
|
ignore_errors: yes
|
|
|
|
- name: Show ports
|
|
ansible.builtin.debug:
|
|
var: ports.stdout_lines
|
|
|
|
- name: Test sshd configuration
|
|
ansible.builtin.command: sshd -t
|
|
register: sshd_test
|
|
ignore_errors: yes
|
|
|
|
- name: Show config test result
|
|
ansible.builtin.debug:
|
|
var: sshd_test.stderr |