"""Check SSH auth with full debug output."""
import subprocess
import sys

# Try SSH with -vvv to get full debug, capturing stderr properly
result = subprocess.run(
    [
        "ssh",
        "-vvv",
        "-i", r"C:\Users\P3\.ssh\id_rsa",
        "-o", "ConnectTimeout=8",
        "-o", "StrictHostKeyChecking=no",
        "-o", "BatchMode=yes",
        "-o", "PasswordAuthentication=no",
        "root@91.99.89.7",
        "echo SSH_OK"
    ],
    stdout=subprocess.PIPE,
    stderr=subprocess.STDOUT,  # merge stderr into stdout
    timeout=15
)
output = result.stdout.decode("utf-8", errors="replace")
print(output[-3000:] if len(output) > 3000 else output)
print(f"\nReturn code: {result.returncode}")
