Remote Host Diagnostics
Diagnose remote host health via SSH, Ansible, and nmap. Validates vm_lab_setup and ansible_configure_vm.
Inputs
| Input |
Type |
Default |
Purpose |
host |
string |
required |
Target host to diagnose |
user |
string |
"" |
SSH username |
commands |
string |
hostname && uptime && free -h && df -h |
Commands to run remotely |
gather_facts |
bool |
true |
Gather Ansible facts |
fetch_logs |
bool |
false |
Fetch system logs from host |
Workflow
1. Load Persona
2. Check Known Issues
check_known_issues("ssh", "")
check_known_issues("nmap", "")
3. SSH Configuration
ssh_config_list() — list SSH config entries
ssh_known_hosts_list() — list known hosts
ssh_add_list() — list SSH agent keys
ssh_fingerprint(host="{{ host }}") — target host fingerprint
4. Connectivity
ssh_test(host="{{ host }}")
ssh_command(host="{{ host }}", command="{{ commands }}")
5. Ansible Diagnostics (if gather_facts)
ansible_setup(host="{{ host }}") — system facts
ansible_command(host="{{ host }}", command="uname -a")
ansible_shell(host="{{ host }}", command="systemctl list-units --failed --no-pager; journalctl -p err --since '1 hour ago' --no-pager | tail -20")
6. Fetch Logs (if fetch_logs)
ansible_fetch(host="{{ host }}", src="/var/log/syslog", dest="/tmp/remote_logs/")
7. Network Scanning
nmap_ping_scan(target="{{ host }}")
nmap_service_scan(target="{{ host }}")
8. Failure Learning
- "connection refused" →
learn_tool_fix("ssh_test", "connection refused", "SSH service not running", "sudo systemctl start sshd")
- "no route to host" → host unreachable, check network
- "permission denied" → check SSH key authorization
- "host key verification failed" →
ssh-keygen -R <host> and re-scan
9. Memory
memory_session_log("Remote host diagnostics", "host={{ host }}, gather_facts={{ gather_facts }}")
Error Recovery
| Error |
Action |
| "connection refused" |
Ensure sshd running on target |
| "no route to host" |
Check network, verify host powered on |
| "permission denied" |
Check SSH key, credentials |
| "host key verification failed" |
Remove old key: ssh-keygen -R <host> |
Output
Report: SSH connectivity, fingerprint, agent keys, remote command output, Ansible diagnostics, system facts, network scan (ping, services), known issues.
Chains To
ansible_configure_vm, vm_lab_setup
1---2name: remote-host-diagnostics3description: Diagnose remote host health via SSH, Ansible, and network scanning. Use when debugging SSH connectivity, gathering remote system facts, or troubleshooting VM/remote server issues.4---56# Remote Host Diagnostics78Diagnose remote host health via SSH, Ansible, and nmap. Validates vm_lab_setup and ansible_configure_vm.910## Inputs1112| Input | Type | Default | Purpose |13|-------|------|---------|---------|14| `host` | string | required | Target host to diagnose |15| `user` | string | "" | SSH username |16| `commands` | string | hostname && uptime && free -h && df -h | Commands to run remotely |17| `gather_facts` | bool | true | Gather Ansible facts |18| `fetch_logs` | bool | false | Fetch system logs from host |1920## Workflow2122### 1. Load Persona23- `persona_load("devops")`2425### 2. Check Known Issues26- `check_known_issues("ssh", "")`27- `check_known_issues("nmap", "")`2829### 3. SSH Configuration30- `ssh_config_list()` — list SSH config entries31- `ssh_known_hosts_list()` — list known hosts32- `ssh_add_list()` — list SSH agent keys33- `ssh_fingerprint(host="{{ host }}")` — target host fingerprint3435### 4. Connectivity36- `ssh_test(host="{{ host }}")`37- `ssh_command(host="{{ host }}", command="{{ commands }}")`3839### 5. Ansible Diagnostics (if gather_facts)40- `ansible_setup(host="{{ host }}")` — system facts41- `ansible_command(host="{{ host }}", command="uname -a")`42- `ansible_shell(host="{{ host }}", command="systemctl list-units --failed --no-pager; journalctl -p err --since '1 hour ago' --no-pager | tail -20")`4344### 6. Fetch Logs (if fetch_logs)45- `ansible_fetch(host="{{ host }}", src="/var/log/syslog", dest="/tmp/remote_logs/")`4647### 7. Network Scanning48- `nmap_ping_scan(target="{{ host }}")`49- `nmap_service_scan(target="{{ host }}")`5051### 8. Failure Learning52- "connection refused" → `learn_tool_fix("ssh_test", "connection refused", "SSH service not running", "sudo systemctl start sshd")`53- "no route to host" → host unreachable, check network54- "permission denied" → check SSH key authorization55- "host key verification failed" → `ssh-keygen -R <host>` and re-scan5657### 9. Memory58- `memory_session_log("Remote host diagnostics", "host={{ host }}, gather_facts={{ gather_facts }}")`5960## Error Recovery6162| Error | Action |63|-------|--------|64| "connection refused" | Ensure sshd running on target |65| "no route to host" | Check network, verify host powered on |66| "permission denied" | Check SSH key, credentials |67| "host key verification failed" | Remove old key: `ssh-keygen -R <host>` |6869## Output7071Report: SSH connectivity, fingerprint, agent keys, remote command output, Ansible diagnostics, system facts, network scan (ping, services), known issues.7273## Chains To7475- `ansible_configure_vm`, `vm_lab_setup`