SSH Connection Logic¶
Define Borealis Engine-side SSH behavior for Ansible and future SSH-backed features. This is reference material for implementation and troubleshooting, not normal operator guidance.
Rule¶
When an SSH credential has both password and private key, Borealis chooses one final auth mode per target instead of blindly passing both to Ansible.
Final modes:
keypasswordcombinedonly when required inputs are missing and Borealis cannot decide
Processing Order¶
- Resolve targets into concrete devices.
- Resolve site scope and duplicate hostnames into stable inventory aliases.
- Prepare or refresh WireGuard tunnels.
- Wait for agent-side tunnel readiness for selected SSH port.
- Load selected credential.
- Normalize private key text.
- Reject passphrase-only private keys unless password exists.
- If only key exists, render key-only inventory.
- If only password exists, render password-only inventory.
- If both exist, run mixed-auth probing.
- Build Ansible inventory with one final auth mode per target.
- Run Ansible from isolated workspace.
- Record recap and target/run status.
Mixed-Auth Probe¶
- Run key-only probe first.
- If key probe succeeds, choose
key. - If key probe fails or times out, run one password-only probe.
- If password probe succeeds, choose
password. - If password probe fails or times out, choose
key.
Reason: bad password retries through sshpass can trigger account lockout behavior across a multi-host run.
Inventory Behavior¶
Key-only inventory includes ansible_ssh_private_key_file and disables password/kbd-interactive authentication.
Password-only inventory includes ansible_password and ansible_ssh_password_mechanism: sshpass.
Combined inventory is fallback-only and should not be normal output when probes have enough information.
Runtime Defaults¶
- Control sockets live under short per-run directories beneath
/tmp/ansible_controlplane. - Workspaces live under
Engine/Services/api-backend/cache/Ansible/Generated/Runtime/<run_id>. - Host key checking is disabled because targets use ephemeral WireGuard peer IPs.
- Remote temp defaults to
/tmp/.ansible-borealis. - SSH transfer defaults to
scpwith-O.
Failure Reading¶
permission_deniedduring key probe: key not accepted for user/host; try password probe if present.ssh_session_timeoutduring key probe: inconclusive; try password probe if present.permission_deniedduring password probe: password not accepted or password auth denied; keep key-only.ssh_session_timeoutduring password probe: inconclusive; keep key-only.- Ansible recap
Permission denied (publickey,password): final selected auth material failed at OpenSSH layer.
Detailed Codex Breakdown
Related documentation¶
Source map¶
- Credential host-var rendering:
Data/Engine/Containers/api-backend/data/services/ansible/ssh_auth.py - Scheduled Ansible decision logic:
Data/Engine/Containers/api-backend/data/services/API/scheduled_jobs/job_scheduler.py - Ansible workspace/config generation:
Data/Engine/Containers/api-backend/data/services/ansible/runner.py - Workflow Ansible target rendering:
Data/Engine/Containers/api-backend/data/services/workflows/runtime.py - Unit coverage:
Data/Engine/Unit_Tests/test_scheduled_jobs_api.py,Data/Engine/Unit_Tests/test_ansible_runner.py,Data/Engine/Unit_Tests/test_workflow_runtime.py
Guardrails¶
- Reuse
apply_ssh_credential_host_vars(...). - Keep scheduler auth resolver behavior authoritative until a shared SSH auth service is extracted.
- Never log password, private key, key passphrase, become password, or secret-bearing command lines.
- If SSH behavior changes, run: